0

I have connectivity to a remote server we can call B, but need to download files from another server called C, which can only be accessed from B and not from my local computer. Is there any way of using B to reach C and get my files from there using only SFTP? I'm currently using python and paramiko.

Something like this: A <-> B <-> C and want to get/put files from A to C.

The simple SFTP connection to B is working as intended so no issues with that.

I tried asking ChatGPT but returned some nonsense:

ssh_to_b = paramiko.SSHClient()
ssh_to_b.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_to_b.connect(ipb, username=userb, password=passb)

ssh_to_c = paramiko.SSHClient()
ssh_to_c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_to_c.connect(ipc, username=userc, password=passc)

transport_to_b = ssh_to_b.get_transport()
channel_to_b = transport_to_b.open_channel('direct-tcpip', (ipc, 22), (my_ip, 22))
transport_to_c = paramiko.Transport(channel_to_b)
transport_to_c.connect(username=userc, password=passc)
sftp_to_c = paramiko.SFTPClient.from_transport(transport_to_c)
alanwech
  • 1
  • 1

0 Answers0