且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

“getaddrinfo 失败"使用 Paramiko 连接到 SFTP 服务器时

更新时间:2022-11-03 19:28:44

SSHClient.connect 应该包含一个 主机名(或在您的情况下为 IP 地址)–不是任何类型的网址.

The hostname parameter of SSHClient.connect should contain a hostname only (or in your case an IP address) – not any kind of URL.

ssh_client.connect(hostname="81.149.151.143", port=220, username=..., password=...)

强制性警告:请勿以这种方式使用 AutoAddPolicy – 您将失去针对 MITM 攻击 这样做.如需正确的解决方案,请参阅Paramiko未知服务器".


Obligatory warning: Do not use AutoAddPolicy this way – You are losing a protection against MITM attacks by doing so. For a correct solution, see Paramiko "Unknown Server".