使用製品:VSR1000、バージョン番号は次のとおりです。バージョン7.1.059、ESS 0323L03。
問題:
Paramikoモジュールあなたが示唆、SSHプロトコルエラー介して接続されたVSRデバイスをログインしたときに、Python言語を使用して:paramiko.ssh_excetion.SSHException:チャネルが閉じ。詳細については、スクリーンショットを参照してください。
paramiko.ssh_exception.SSHException:チャネルが閉じ。===== invoke_shell()
次のように正しい解決策は以下のとおりです。
H3C设备登录记录
#!/user/bin/env python
import sys
import paramiko
import time
def Testsshcon(ip,port,username,password):
try:
sshcon=paramiko.SSHClient()
sshcon.set_missing_host_key_policy(paramiko.AutoAddPolicy())
sshcon.connect(ip,port,username,password,compress=True)
#print "ok"
#print 'ipaddress %s,port %d,uername %s,password %s'%(ip,port,username,password)
print "ssh secuees"
cmds=['dis cpu\n','dis version\n']
conn=sshcon.invoke_shell()
for cmd in cmds:
time.sleep(1)
conn.send(cmd)
time.sleep(1)
print "command"
out=conn.recv(1024)
print out
sshcon.close()
except Exception,e:
print "connet error",e
if __name__=="__main__":
Testsshcon('10.10.10.10',22,'username','password')