First of all, you need to create a configuration file in ~/.ssh/config
and write into it something like:
Host src_host
HostName example.com
User user1
Port 22
IdentitiesOnly yes
IdentityFile /path/to/secret-key
Host dest_host
HostName 99.111.22.333
User user2
Port 3333
IdentitiesOnly yes
IdentityFile /path/to/secret-key2
Then, you can check whether the configuration file is working with ssh -F ~/.ssh/config src_host
, where -F
allows you to specify a non-default path to a configuration file. I had to go through this process, since ssh
was ignoring ~/.ssh/config
.
Finally, you can scp
between the two hosts:
scp -3v -F .ssh/config src-host:/path/to/file1 dest-host:/path/to/file2
-3
directs the traffic through your machine
-v
produces a verbose output