使用pysftp通过跳转服务器连接

Using pysftp to connect via jump server

我正在尝试通过 pysftp 将文件上传到我的家庭网络。我的本地设备通过 WireGuard 连接到 VPS.

我可以使用ssh跳转连接到本地设备

ssh -J user@VPS user@localdevice

有什么方法可以用 pysftp 做同样的事情吗?

像这样

import pysftp

with pysftp.Connection('hostname', username='me', password='secret') as sftp:

    with sftp.cd('/allcode'):           # temporarily chdir to allcode
        sftp.put('/pycode/filename')    # upload file to allcode/pycode on remote
        sftp.get('remote_file')         # get a remote file

https://www.tutorialspoint.com/python_network_programming/python_sftp.htm

虽然也可以使用 pysftp 通过跳转服务器进行连接,但对于这样的技术任务来说,它是太高级的库了。并且 pysftp 似乎也是一个死气沉沉的废弃项目。参见

直接使用 Paramiko(pysftp 只是 Paramiko 之上的包装器)。参见