溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

h3c設(shè)備使用paramiko模塊連接(SSHException:Channel closed)

發(fā)布時間:2020-07-22 18:23:15 來源:網(wǎng)絡(luò) 閱讀:1266 作者:chier11 欄目:系統(tǒng)運(yùn)維

使用產(chǎn)品為:VSR1000,版本號為:Version 7.1.059, ESS 0323L03。

問題:

使用python語言的paramiko模塊,通過ssh協(xié)議登錄連接VSR設(shè)備時報錯,提示: paramiko.ssh_excetion.SSHException:Channel closed。詳細(xì)信息見截圖。
h3c設(shè)備使用paramiko模塊連接(SSHException:Channel  closed)

paramiko.ssh_exception.SSHException: Channel closed. ===== invoke_shell()

正確的解決方法如下:

h3c設(shè)備使用paramiko模塊連接(SSHException:Channel  closed)

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')
向AI問一下細(xì)節(jié)

免責(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)容。

AI