【问题标题】:FTP connection working on FileZilla and command line but not python ftplibFTP 连接在 FileZilla 和命令行上工作,但不是 python ftplib
【发布时间】:2020-05-01 06:19:31
【问题描述】:

我在 aws 上部署了一个 ftp 服务器。我可以从 FileZilla 和命令行连接到它。但是,我给了我的python脚本:

OSError: [Errno 101] 网络不可达

我知道我的脚本可以工作,因为我可以连接到其他服务器。

def test_connection():
   server = ftplib.FTP()
   server.connect('xx.xxx.xxx.xx')
   server.login('xxxx', 'xxx')
   print(server.dir())
   server.quit()

if __name__ == "__main__":
   test_connection()

有什么线索吗?

非常感谢:)

【问题讨论】:

    标签: python ftplib vsftpd


    【解决方案1】:

    您可能希望重组代码,以便在 FTP 构造函数调用中初始化凭据。

    import ftplib
    server= ftplib.FTP('server.address.com','USERNAME','PASSWORD')
    print(server.dir())
    session.quit()
    

    如果您的 FTP 主机需要 TLS,请改用 ftplib.FTP_TLS

    【讨论】:

      【解决方案2】:

      最终效果如何:

      我更改了 vsftpd 配置:

      听=是 listen_ipv6=否

      虽然不完全确定是什么问题

      【讨论】:

        猜你喜欢
        • 2011-11-10
        • 2012-05-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-12-29
        • 2011-03-21
        相关资源
        最近更新 更多