Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

What arguments would I use for the scp command on a server to server copy if the two servers need different ssh keys? I know how to scp files from a server to a server without having data flow on the PC (the one from which I issued the scp command).

Based on this tutorial, my starting command looks something like this:

scp -r miguel@10.1.2.2:/home/miguel/ miguel@10.1.2.3:/home/miguel/
share|improve this question
    
I would question your statement that scping from one remote host to another using a third machine to issue the command doesn't transfer data over the wire to your local PC to and from the remotes. Are you sure about that or is this just a convenience command for what gets run as a two step process? –  Caleb Jun 26 '11 at 21:17
add comment

2 Answers

up vote 3 down vote accepted

Use ssh-agent and ssh-add all the keys you need to it.

Example:

# 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 first@host1.example.com:file1 second@host2.example.com:file2
share|improve this answer
    
is this working? –  LanceBaynes Jun 27 '11 at 5:34
add comment

EDIT: I was wrong about the transfer through localhost. The manual I read didn't clarify it.

You have to setup a key pair for authentication from server1 to server2. So, you must be able to connect from your system to server1 and from server1 to server2. You effectively run ssh user@server1 scp -r files user@server2:files

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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