Having not the reputation points required, I can't add a comment on Chris Davies's answer. However, I don't think everybody will be able to have his solution working without some help.
ssh -R localhost:50000:host2:22 host1 'rsync -e "ssh -p 50000" -vuar /var/www localhost:/var/www'
means that you ssh to host1 while building a tunnel to host2 trough the intermediate server. And on host1, you execute the rsync command using ssh to reach the target machine. If you are unlucky, it won't work and if you slightly modify the command, you'll know why :
ssh -R localhost:50000:host2:22 host1 'rsync -e "ssh -vv -p 50000" -vuar /var/www localhost:/var/www'
You'll get messages such as :
debug1: load_hostkeys: fopen /home/ubuntu/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
This means that .ssh/known_hosts was found on host1 but since the destination is not known from ssh, it attempts to find it elsewhere. And since you are not in an interactive shell, it can't ask the question :
The authenticity of host 'host2 (host2)' can't be established.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
To solve this, the simplest way is to build a temporary tunnel :
ssh -R localhost:50000:host2:22 host1 'sleep 60'
and then get to host1 and from there, run the ssh command :
ssh -p 50000 localhost
(which means "ssh host2") in order to validate the host. This being done, the accepted solution should be working.
Nota : this question should be merged with rsync files between two remotes, with only access from the "intermediate"
sshfs
is that thenrsync
sees the source and destination filesystems both as local, so it disables its delta algorithm. At that point you almost might as well just usecp -p
. See the answer that proposes this and its subsequent comments.scp -3 A:file C:file
superuser.com/a/401245/264813