这有效:cnopts = pysftp.CnOpts()cnopts.hostkeys = Nonewith pysftp.Connection('ftpsite.com', username='xxx', password='xxx', cnopts=cnopts) as sftp: with sftp.cd('inbox'): sftp.get('WinSCP.ini') 但现在我想直接测试 ftp(端口 21),所以我添加了端口属性:with pysftp.Connection('ftpsite.com', port=21 , username='xxx', password='xxx', cnopts=cnopts) as sftp:现在我明白了:异常:paramiko.ssh_exception.SSHException 消息:读取 SSH 协议横幅时出错我很困惑...
2 回答

哈士奇WWW
TA贡献1799条经验 获得超6个赞
pysftp 库仅使用 SFTP 协议进行对话,这与“普通”FTP 协议不同。因此,当您的程序尝试通过 SFTP 与 FTP 服务器通信时,您看到的是错误,并且不理解它返回的响应。

冉冉说
TA贡献1877条经验 获得超1个赞
SFTP 使用 SSH,所以它的端口是 22,而不是 21
FTP 使用端口 21
就像错误所说的,ssh 异常。尝试使用 'port=22'
来源:
port 21 Yes, and SCTP Assigned Official File Transfer Protocol (FTP) control (command)
port 22 Yes, and SCTP Assigned Official Secure Shell (SSH), secure logins, file transfers (scp, sftp) and port forwarding
添加回答
举报
0/150
提交
取消