python connecting to ssh An existing connection was forcibly closed by the remote host

帅比萌擦擦* 提交于 2019-12-12 03:08:57

问题


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()

I get this error which is,

paramiko.ssh_exception.SSHException: Error reading SSH protocol banner[WinError 10054] An existing connection was forcibly closed by the remote host

This only happens SOMETIMES


回答1:


You are closing your connection inside your function at ssh.close(), isn't it the problem?



来源:https://stackoverflow.com/questions/42796765/python-connecting-to-ssh-an-existing-connection-was-forcibly-closed-by-the-remot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!