rsync through ssh tunnel

simona picture simona · May 20, 2013 · Viewed 49.8k times · Source

I want to rsync to a cluster node to which I usually connect passing through another system:

Say I connect first to

  ssh user@bridge 

and from there to

  ssh user@clusternode

Now I want to rsync from my workstation to clusternode. I do the following:

  • I open a ssh tunnel

    ssh -L8000:clusternode:8000 user@bridge
    
  • I rsync from my workstation to clusternode

    rsync -e "ssh -p8000" source user@localhost:destination
    

and it does not work, I get

 ssh_exchange_identification: Connection closed by remote host

Why does it not work? What do I have to do?


I have found a lot of information here:

http://toddharris.net/blog/2005/10/23/rsyncing-through-an-ssh-tunnel/

I think to understand that my problem is the second authentication between the bridge and the destination, so I changed to method 2 that is also not very elegant, but it works. I would like to try method 3, but I don't know how to configure a rsync daemon

Answer

skroll picture skroll · Feb 14, 2014

Try this one-liner:

rsync -av -e "ssh -A root@proxy ssh" ./src root@target:/dst