rsync through ssh tunnel [closed]

三世轮回 提交于 2019-12-03 01:53:09

问题


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


回答1:


Here's what worked for me.

I run a command in the background to tunnel to the remote host:

 ssh -N -L 2222:remote.example.com:22 bridge.example.com&

then I rsync to localhost like this:

rsync -auve "ssh -p 2222" . me@localhost:/some/path



回答2:


Try this one-liner:

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



回答3:


You should connect to the port 22 of clusternode, so the tunnel should look like

ssh -L localhost:8000:clusternode:22 user@bridge


来源:https://stackoverflow.com/questions/16654751/rsync-through-ssh-tunnel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!