Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pysftp vs. Paramiko

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?

like image 880
Jorjani Avatar asked Jan 25 '18 03:01

Jorjani


1 Answers

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.

    • Python pysftp put_r does not work on Windows
    • Python pysftp get_r from Linux works fine on Linux but not on Windows
    • "Failed to load HostKeys" warning while connecting to SFTP server with pysftp
    • pysftp supports only RSA and DSA private keys. Paramiko supports even Ed25519 and ECDSA keys.
  • 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 is 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:

    • Python pysftp put_r does not work on Windows
    • Python pysftp get_r from Linux works fine on Linux but not on Windows
  • You can access some Paramiko functionality not exposed in pysftp by using pysftp Connection.sftp_client, which returns underlying Paramiko SFTPClient object. For an example, see pysftp: How to update last modified date.

like image 106
Martin Prikryl Avatar answered Oct 28 '22 01:10

Martin Prikryl