FTPES - 在 Python 中通过显式 TLS/SSL 的 FTP

新手上路,请多包涵

我需要一个 python 客户端来执行 FTPES(显式),有没有人有使用任何可以执行此操作的 python 包的经验。

我无法在 python 中执行此操作,但可以使用 FileZilla 等工具连接到 FTP 服务器

谢谢

原文由 user424060 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 819
1 个回答

本地 Python 很好地支持 FTP-SSL Explicit。建立连接后,您可以使用所有标准的 ftplib 命令。可以在以下位置找到更多信息:http: //docs.python.org/2/library/ftplib.html#ftplib.FTP_TLS

这是下载文件的基本示例:

 from ftplib import FTP_TLS
ftps = FTP_TLS('ftp.MySite.com')
# login after securing control channel
ftps.login('testuser', 'testpass')
# switch to secure data connection..
# IMPORTANT! Otherwise, only the user and password is encrypted and
# not all the file data.
ftps.prot_p()
ftps.retrlines('LIST')

filename = 'remote_filename.bin'
print 'Opening local file ' + filename
with open(filename, 'wb') as myfile:
    ftps.retrbinary('RETR %s' % filename, myfile.write)

ftps.close()

原文由 SilentSteel 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题