Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a large amount of data to send from one server to another. I access servers via ssh using a private key.

The problem is that I cannot use that key to scp files from one such server to another - server One doesn't have the private key which server Two expects (only the public part), so Two won't allow access from One.

The only way to send files would be to get them to my computer first (too slow), send private key to one of the servers (probably won't explode in this case, but I really really hate such solutions), or create extra accounts just for that or one of the servers.

Doesn't ssh have some way to let an ssh session forward authorization? That would be really great.

share|improve this question
up vote 6 down vote accepted

Assuming you have the same public key present in ~/.ssh/authorized_keys on both servers, and that you are running some kind of ssh agent locally, then you can use Agent forwarding.

localcomputer$ ssh -o ForwardAgent=yes

That way, when you from run your scp session against server.two the authentication will transparently be handled in the background by your local computer . Just note the following warning, taken from ssh_config(5)

Agent forwarding should be enabled with caution. Users with the ability to bypass file permissions on the remote host (for the agent's Unix-domain socket) can access the local agent through the forwarded connection. An attacker cannot obtain key material from the agent, however they can perform operations on the keys that enable them to authenticate using the identities loaded into the agent.

(In short, to a certain degree you will have to trust

share|improve this answer
Note that might not work with scp as it explicitly disables agent forwarding. – Tgr Aug 19 '11 at 12:13
You can enable agent forwarding with scp by using the -o flag which allows setting SSH options like in ssh_config. For example, scp -o "ForwardAgent yes" user@host1:/path/to/file user@host2:/path/to/directory – Isaac Aggrey Jun 19 '15 at 23:23

On a sidenote :

If you're sending large data volumes, you'd better use tar-over-ssh, instead of scp. Is really much faster.

see howto use tar over ssh

share|improve this answer

Your Answer


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.