Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

H3C devices use paramiko module connection (SSHException:Channel closed)

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

The product used is VSR1000, and the version number is Version 7.1.059, ESS 0323L03.

Question:

Use python language paramiko module, login through ssh protocol to connect to VSR device Times error, prompt: paramiko.ssh_excetion.SSHException:Channel closed. See the screenshot for details.

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

The correct solution is as follows:

H3C device login record #! / user/bin/env pythonimport sysimport paramikoimport timedef 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% ipaddress port% d department uername% s department password% s record% (ip,port,username) Password) print "ssh secuees" cmds= ['dis cpu\ nZhe Zhendis 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", eif _ _ name__== "_ _ main__": Testsshcon ('10.10.10.10.10)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report