使用产品为:VSR1000,版本号为:Version 7.1.059, ESS 0323L03。
问题:
使用python语言的paramiko模块,通过ssh协议登录连接VSR设备时报错,提示: paramiko.ssh_excetion.SSHException:Channel closed。详细信息见截图。
paramiko.ssh_exception.SSHException: Channel closed.
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‘)
原文地址:https://blog.51cto.com/chier11/2461576
时间: 2024-10-28 06:51:23