python连接到ssh一个现有的连接被远程主机强行关闭 [英] python connecting to ssh An existing connection was forcibly closed by the remote host
本文介绍了python连接到ssh一个现有的连接被远程主机强行关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试连接到我的服务器时
When I try connecting to my server
class ConnectToServer():
def connect_to_vps(self):
port = 22
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(self.IP, port=port, username="root", password="123", timeout=3)
ssh.close()
scanner = ConnectToServer()
scanner.connect_to_ssh()
我收到这个错误,
paramiko.ssh_exception.SSHException:读取 SSH 协议横幅时出错[WinError 10054] 远程主机强行关闭了现有连接
paramiko.ssh_exception.SSHException: Error reading SSH protocol banner[WinError 10054] An existing connection was forcibly closed by the remote host
这种情况有时会发生
推荐答案
您正在 ssh.close() 处关闭函数内部的连接,这不是问题吗?
You are closing your connection inside your function at ssh.close(), isn't it the problem?
这篇关于python连接到ssh一个现有的连接被远程主机强行关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文