通过多个ssh隧道复制文件

我有一个尴尬的情况,我需要通过多个隧道链接到一台机器。 详情为什么在下面,但是这个命令适用于sshing到server2

 ssh -A -t [email protected] ssh -A -t [email protected] ssh -A -t [email protected] ssh -A [email protected] 

(为简洁起见,该命令现在是$ssh_cmd )如何使用类似的隧道设置将文件复制到/从该机器? 我曾尝试过,例如:

 rsync --rsh=ssh -e "$ssh_cmd" [email protected]:filename . 

即使在删除-t ,它也会失败,因为它不会给我input密码的机会:

 debug1: Next authentication method: password debug1: read_passphrase: can't open /dev/tty: No such device or address debug1: Authentications that can continue: publickey,password Permission denied, please try again. 

那么如何设置这个隧道复制命令呢?

额外的细节:

  • portal1阻止代理命令,这需要额外的这些跳转,并防止方便的.ssh/config hackery
  • 失败的身份validation似乎至less阻止了我一次

编辑:build议使用基于密钥的身份validation,这工作到一个点,然后失败:

 debug1: Host 'server2.host2.org' is known and matches the ECDSA host key. debug1: Found key in /home/username2/.ssh/known_hosts:3 debug1: read_passphrase: can't open /dev/tty: No such device or address Host key verification failed. 

我不明白; 如果它find了关键为什么不使用它?

答案是,至less在一定程度上,我的rsync命令是错误的。 上面的ssh命令应该排除对用户名/主机的最后一个引用,即:

 ssh -A -t [email protected] ssh -A -t [email protected] ssh -A -t [email protected] ssh -A 

而不是上面显示的命令。 这在debugging输出中变得明显:

 debug1: Sending command: ssh -Av [email protected] -l username2 server2.host2.org rsync --server --sender -vvulogDtprCe.iLs . filename bash: server2.host2.org: command not found 

在那里冗余地指定服务器,从而使服务器名称被远程解释为命令。

对于authentication失败,使用基于密钥的authentication解决了问题。

我还添加了-o StrictHostKeyChecking=no来处理主机密钥validation失败。