The closest suggestion I can come up with is using ssh-agent
- Start an agent, if you don't already have one:
ssh-agent bash
- Load a key:
ssh-add
ssh
to one host and have it initiate a copy to/from the other: scp user@server1:path user@server2:path
Instead of using scp
without the -3
flag, you can explicitly ssh
to one host and start scp
, then you get to decide if you will ssh
to server1
or server2
. With the command I gave above, scp
will choose one for you.
From a security perspective there is a danger in using ssh-agent
, as the server will have full access to using keys in your agent even for other purposes than this file transfer.
If you don't want to trust either server with access to the other, but want to ensure that only the client host has access to the keys and the servers communicate securely with each other, but will only transfer the file you have specified and do nothing else, then you are going to need some different tool. I don't think that can be achieved with scp
.