Yes this is possible, but only if server1.com
can reach server2.com
by using that name. If not you will probably get a message: ssh: connect to host server2 port 22: Connection refused
The man
page for scp
clearly states that it copies between hosts on a network and that:
Copies between two remote hosts are also permitted.
What you should do (once) is ssh
to username@server1.com
and from there ssh
to username@server2.com
. Answer the authenticity question you'll get with yes, to get rid of the host key verification message while doing the scp
You might have to enable the forwarding agent with:
scp -o "ForwardAgent yes" -r usrname@server1.com:~/data/* usrname@server2.com:~/data/
But make sure you realise the danger in that (man ssh_config
)