Search code examples
unixsshscp

How to transfer a file between two remote servers using scp from a third, local machine?


I'm trying to copy a file from one remote server to another remote server from my local machine. Here's what I'm trying to do

localA $ scp userB@remoteB:/path/to/file userC@remoteC:/path

The problem is that I need to pass two passwords for both userB and userC on the remote machines.

According to Garron the above should work, but I got permission denied.

Permission denied (gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive).
lost connection

Any suggestions?


Solution

  • 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