1

I'm following the answer on How to scp from server to server with different public keys? but I'm getting a connection error:

# start the agent and capture its environment in the current shell
eval `ssh-agent`

# add keys needed to connect to the different accounts
ssh-add /path/to/first/ssh/key
ssh-add /path/to/second/ssh/key

# do the copying

$ scp -r user@server1:/images user@server2:/images
ssh: connect to host server2 port 22: Connection timed out
lost connection

It works if I use my machine as an explicit intermediary:

$ scp -r user@server1:/images /images
$ scp -r /images user@server2:/images

Any clues on why it's failing to do the copy in one step?

4

A remote-to-remote scp actually works by logging into the first machine using ssh, and running scp from there. So, basically, server1 can't connect to server2 (presumably, due to a firewall rule).

You can add the -3 option to route the copy through your local machine, avoiding the above issue. The documentation for OpenSSH 6.5 at least warns that you'll not get a progress meter.

(Note: scp didn't used to do remote-to-remote transfers; one side was required to be local. So this is a somewhat new feature.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.