paramiko.SSHException:读取 SSH 协议横幅时出错 [英] paramiko.SSHException: Error reading SSH protocol banner

查看:261
本文介绍了paramiko.SSHException:读取 SSH 协议横幅时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Paramiko 并尝试连接到我的 SFTP 服务器.这是我写的代码:

I am using Paramiko and trying to connect to my SFTP server. Here is the code I wrote:

class SFTPUploader:
    def __init__(self, host, username, password, port):
        transport = paramiko.Transport((host, port))
        print transport
        transport.connect(username = username, password = password)
        self.sftp = paramiko.SFTPClient.from_transport(transport)

我可以从终端连接到我的服务器.这个话题没有帮助,因为我们的场景不同.

I can connect to my server from the terminal. This thread didn't help since our scenario is different.

推荐答案

当 paramiko 没有收到协议横幅,或者服务器发送一些无效的东西时,就会产生这个错误.如果服务器以其他方式正常工作,这可能是由于某些网络限制所致.

That error is generated when paramiko doesn't receive a protocol banner, or the server sends something invalid. If the server is otherwise working correctly, this may be due to some network restrictions.

您可以使用 -vvv 作为 openssh 客户端的一个选项来获取有关它如何连接的更多信息,并且您可以在端口 22 上使用 netcat 或 telnet 轻松获取实际横幅.横幅应该以'SSH-'开头,否则paramiko会立即返回上述错误.

You can use -vvv as an option to the openssh client to get more information about how it's connecting, and you can get the actual banner easily using netcat or telnet on port 22. The banner should start with 'SSH-', or paramiko will return the above error immediately.

这篇关于paramiko.SSHException:读取 SSH 协议横幅时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆