1

I am trying to upload a file to my home network via pysftp. My local device is connected via WireGuard to a VPS.

I can use ssh jumps to connect to the local device with

ssh -J user@VPS user@localdevice

Is there any way to do the same with pysftp?

Martin Prikryl
  • 167,268
  • 50
  • 405
  • 846
A-wels
  • 67
  • 6

2 Answers2

1

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

Martin Prikryl
  • 167,268
  • 50
  • 405
  • 846
-1

Something like this

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

Lewis Morris
  • 1,427
  • 1
  • 20
  • 28