Pysftp VS. Paramiko

pysftp vs. Paramiko

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.

Using pysftp to connect via jump server

While it's probably possible to connect via jump servers using pysftp too, it's too high-level library to such technical task. And pysftp also seems to be a dead and abandoned project. See pysftp vs. Paramiko.

Use Paramiko directly (pysftp is just a wrapper on top of Paramiko). See

Nested SSH using Python Paramiko

Use custom command to start SFTP server in pysftp/Paramiko

What that option in WinSCP does is that it runs SFTP over the "exec" channel, instead of the "sftp subsystem" channel. An (untested) equivalent in Python Paramiko:

ssh = paramiko.SSHClient()

# authenticate here

chan = ssh.get_transport().open_session()
chan.exec_command("/path/to/sftp-server")
sftp = paramiko.SFTPClient(chan)

How to verify a successful upload if I use pysftp to transfer a file?

Pysftp Connection.put already checks the size of the uploaded file. That's what the confirm=True parameter is for, You do not need to do anything more:

whether to do a stat() on the file afterwards to confirm the file size

While you can theoretically verify the checksum with SFTPFile.check, it won't typically work, as most SFTP servers, including the widespread OpenSSH, do not support calculating checksums. So the call will fail. You would have to resort to running some shell command to calculate the checksum. See:

Comparing MD5 of downloaded files against files on an SFTP server in Python

But it's questionable whether it is worth the effort, see:

How to perform checksums during a SFTP file transfer for data integrity?


Though these days, you should not use pysftp, as it is dead. Use Paramiko directly instead. See pysftp vs. Paramiko. See basically the same question about Paramiko: How to check if Paramiko successfully uploaded a file to an SFTP server?

Pysftp fails with Authentication failed and Server did not send a server-sig-algs list; defaulting to our first preferred algo ('rsa-sha2-512')

The error comes from underlying Paramiko and is discussed here:

Paramiko authentication fails with "Agreed upon 'rsa-sha2-512' pubkey algorithm" (and "unsupported public key algorithm: rsa-sha2-512" in sshd log)

Though pysftp does not expose the disabled_algorithms parameter.

You better switch to using Paramiko directly. The pysftp is abandoned project. See pysftp vs. Paramiko.



Related Topics



Leave a reply



Submit