How to transfer a file between two remote servers using scp from a third, local machine?
If you can ssh to both remote servers from your local (local -> remote1 & local -> remote2), then you could try:
ssh -A -t user1@remote1 scp srcpath user2@remote2:destpath
This will transfer straight from remote1 to remote2 using your local credentials all the way.
If you do not want to be asked for passwords, then you should set up the authorized_keys file on remotes.
This questions already exists on Superuser:
https://superuser.com/questions/686394/scp-between-two-remote-hosts-from-my-third-pc
scp -3 user1@remote1:/home/user1/file1.txt user2@remote2:/home/user2/file1.txt
As described there -3 option instructs scp to route traffic through the PC on which the command is issued.
The above is true if remote1 and remote2 are on the same network.
In case not:- You have to use port forwarding
This is possible using the following command line in linux terminal :
scp -3 user1@ip:path/from/directory/ user2@ip:path/to/directory
a prompt will appear asking for passwords like this:
user1@ip's password: user2@ip's password:
If you give both passwords in order by pressing enter after the first password, it should accept but it wont. Even if you give both passwords again in order but by not pressing enter after the first password, it wont accept again.
You have to give user2's first, then press enter and then type user1's password and press enter. This will work.
I know it doesn't sounds right, but only this will work. This is a bug in scp.