I have a simple requirement to drop a file on an SFTP server. I have found pysftp and Paramiko libraries that seem to allow me to this and developed a simple application using Paramiko but I can’t find a proper source that compares the two so I can decide which one I can/should use. What are the pros and cons for each?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
pysftp is a wrapper around Paramiko with a more Python-ish interface.
pysftp interface does not expose all of the features of Paramiko. On the other hand, pysftp implements more high-level features on top of Paramiko, notably recursive file transfers.
- pysftp has not been updated since 2016, so it seems abandoned project. It has also some significant issues in its latest release that were never fixed. Particularly when used on Windows, the recursive transfers do not work. So on Windows pysftp has no significant advantage over (maintained) Paramiko.
- If you do not have any fancy low-level needs (like unusual methods of verifying host key, proxies, advanced keyboard interactive authentication, setting a timeout, etc), pysftp may be easier to work with. On the other hands, as pysftp seems dead, it probably not good idea to start new development with it.
- If you need low-level features, use Paramiko.
- If you need both low-level features of Paramiko and high-level features of pysftp, use Paramiko and check pysftp code for the high-level features. Alternatively, a complete and platform-independent implementation of recursive transfers is also shown in my answers to:
-
You can access some Paramiko functionality not exposed in pysftp by using pysftp
Connection.sftp_client, which returns underlying ParamikoSFTPClientobject. For an example, see pysftp: How to update last modified date.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0