nix*_*xda 5 windows ssh powershell cisco
我成功地通过 SSH 连接到 Cisco IE-2000-L 交换机。我使用了Renci SSH.NET库。
入门指南:http : //vwiki.co.uk/SSH_Client_(PowerShell)
# Load SSH library (for .NET 4.0 and PowerShell 3)
$DllPath = "D:\temp\Renci.SshNet.dll"
[void][reflection.assembly]::LoadFrom( (Resolve-Path $DllPath) )
# Connect to switch (Cisco IE2000-L) with IP, port, username, password
$SshClient = New-Object Renci.SshNet.SshClient('172.20.91.30', 22, 'admin', 'mypassword')
$SshClient.Connect()
# execute one command on Cisco switch
$SshCommand = $SshClient.RunCommand('show arp')
# show result
$SshCommand.Result 
# close SSH connection
$SshCommand.Dispose()
$SshClient.Disconnect()
$SshClient.Dispose()
上面的代码只发送一个命令。但是我想在不关闭和重新打开会话的情况下连续执行几个命令。
如果我在第一个命令之后添加第二个命令
# execute one command on Cisco switch
$SshCommand = $SshClient.RunCommand('show arp')
$SshCommand = $SshClient.RunCommand('show start')
...脚本挂起并且永远不会完成。我究竟做错了什么?
次要相关信息
cmd输入。它不够可靠。它有时有效,有时无效。| 归档时间: | 
 | 
| 查看次数: | 8689 次 | 
| 最近记录: |