1

I want to transfer a file between two remote servers (R1 and R2) which can't talk to each other. My machine (let's say L) can talk to both R1 and R2. Is there a way to use my local machine as the intermediate host?

Here's the situation

L ----> R1
L ----> R2
R1 ---x--> R2

I want to send files from R1 to R2 using L.

R1 ----> L ----> R2

I found some resources here and here, but can't figure out the syntax to use local machine as intermediate host.

1 Answers1

1

scp has the ability to copy files from one remote host to another remote host:

scp user1@host1:/some/file user2@host2:/some/directory/

This copies /some/file on the first host to /some/directory on the second host.

Normally, scp implements this by connecting to host1 and invoking scp on host1 to transfer files to host2. You say this won't work for you.

scp has an option to transfer files using between two remote hosts, using the local host as an intermediary:

 scp -3 user1@host1:/some/file user2@host2:/some/directory/
     ^^

When run in this fashion, the local scp instance will open two connections, one to each host. One connection will send /some/file to the local host. The other connection will receive files and write them to /some/directory. The local scp instance relays data between the two connections. This should do what you want.

Kenster
  • 8,620