Use products: VSR1000, the version number is: Version 7.1.059, ESS 0323L03.
problem:
Paramiko module using python language, when you log VSR devices connected via ssh protocol error, suggesting: paramiko.ssh_excetion.SSHException: Channel closed. For more information see screenshot.
paramiko.ssh_exception.SSHException: Channel closed. ===== invoke_shell()
The correct solution is as follows:
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')