我一直在使用我的腳本的unix服務器,它的工作完美。但是,當我使用相同的腳本(通過一些較小的命令更改)連接到HP Procurve交換機時,腳本崩潰並出現錯誤。該腳本的一部分是低於:paramiko ssh客戶端不能與惠普交換機一起工作
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(address, username=userna, password=passwd)
stdin,stdout,stderr= ssh.exec_command("show ver")
for line in stdout:
print '... ' + line.strip('\n')
ssh.close()
這給了錯誤
Traceback (most recent call last):
File "C:/Users/kucar/Desktop/my_python/switchmodel", line 34, in <module>
stdin,stdout,stderr= ssh.exec_command("show ver")
File "C:\Python27\lib\site-packages\paramiko\client.py", line 379, in exec_command
chan.exec_command(command)
File "C:\Python27\lib\site-packages\paramiko\channel.py", line 218, in exec_command
self._wait_for_event()
File "C:\Python27\lib\site-packages\paramiko\channel.py", line 1122, in _wait_for_event
raise e
SSHException: Channel closed.
我發現類似投訴在網上卻好像完全不提供解決方案。開關打開ssh並且用膩子工作正常。感謝您提供任何可以幫助我的想法。我無法爲100個開關手動執行「show ver」命令。