Directory transfers with Paramiko

前端 未结 10 891
刺人心
刺人心 2020-11-30 07:25

How do you use Paramiko to transfer complete directories? I\'m trying to use:

sftp.put(\"/Folder1\",\"/Folder2\")

which is giving me this e

10条回答
  •  孤城傲影
    2020-11-30 07:57

    Paramiko does not support directory transfers on its own. You have to implement it, as many existing answers here show.

    Or you can use pysftp. It's a wrapper around Paramiko that has more Python-ish look and feel and supports recursive operations. See

    • pysftp.Connection.put_r()
    • pysftp.Connection.get_r()

    Or you can just base your code on pysftp source code. Full a standalone portable Paramiko-only code see my answers to:

    • Python pysftp get_r from Linux works fine on Linux but not on Windows
    • Python pysftp put_r does not work on Windows

    And as my answers above show, you actually have to use your own code, if you are on Windows, as pysftp does not work there.

提交回复
热议问题