您好,登錄后才能下訂單哦!
使用產(chǎn)品為:VSR1000,版本號為:Version 7.1.059, ESS 0323L03。
問題:
使用python語言的paramiko模塊,通過ssh協(xié)議登錄連接VSR設(shè)備時報錯,提示: paramiko.ssh_excetion.SSHException:Channel closed。詳細(xì)信息見截圖。
paramiko.ssh_exception.SSHException: Channel closed. ===== invoke_shell()
正確的解決方法如下:
H3C設(shè)備登錄記錄
#!/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')
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。