rsync通过ssh隧道

时间:2013-05-20 17:18:16

标签: ssh rsync ssh-tunnel

我想rsync到我通常通过另一个系统连接到的集群节点:

说我先连接到

  ssh user@bridge 

从那里到

  ssh user@clusternode

现在我想从我的工作站rsync到clusternode。我做了以下事情:

  • 我打开一个ssh隧道

    ssh -L8000:clusternode:8000 user@bridge
    
  • 我从工作站rsync到clusternode

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

它不起作用,我得

 ssh_exchange_identification: Connection closed by remote host

为什么不起作用?我该怎么办?


我在这里找到了很多信息:

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

我想要明白我的问题是桥和目的地之间的第二次身份验证,所以我改为方法2,这也不是很优雅,但它的工作原理。我想尝试方法3,但我不知道如何配置rsync守护程序

3 个答案:

答案 0 :(得分:61)

试试这个单行:

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

答案 1 :(得分:30)

这对我有用。

我在后台运行命令以隧道到远程主机:

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

然后我像这样rsync到localhost:

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

答案 2 :(得分:2)

您应该连接到clusternode的端口22,因此隧道应该看起来像

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