我一直在尝试以下命令:
rsync -rvz --progress --remove-sent-files ./dir user@host:2222/path
SSH在端口2222上运行,但是rsync仍然尝试使用端口22,然后抱怨找不到路径,因为它当然不存在。
我想知道是否有可能在非标准的ssh端口上rsync到远程主机。
我一直在尝试以下命令:
rsync -rvz --progress --remove-sent-files ./dir user@host:2222/path
SSH在端口2222上运行,但是rsync仍然尝试使用端口22,然后抱怨找不到路径,因为它当然不存在。
我想知道是否有可能在非标准的ssh端口上rsync到远程主机。
当前回答
我在Mike Hike Hostetler的网站上找到了这个解决方案,它非常适合我。
# rsync -avz -e "ssh -p $portNumber" user@remoteip:/path/to/files/ /local/path/
其他回答
我无法让rsync在不同的端口上通过ssh连接,但我能够通过iptables将ssh连接重定向到我想要的计算机。这不是我想要的解决方案,但它解决了我的问题。
使用“rsh选项”。例如:
rsync -avz --rsh='ssh -p3382' root@remote_server_name:/opt/backups
参考网址:http://www.linuxquestions.org/questions/linux-software-2/rsync-ssh-on-different-port-448112/
运行Linux Ubuntu我使用以下命令
Rsync -rvz——rsh='ssh -p2222'——progress——remove-sent-files ./dir user@host:/path
这将把rsh环境变量作为端口2222上的ssh连接传递。这里的所有其他方法似乎都不适合我的linux风格,所以我想把我的方法提供给其他人。
您还可以通过使用-e命令行选项或设置RSYNC_RSH环境变量来指定您喜欢的任何远程shell。
Rsync文档: https://download.samba.org/pub/rsync/rsync.1
我在Mike Hike Hostetler的网站上找到了这个解决方案,它非常适合我。
# rsync -avz -e "ssh -p $portNumber" user@remoteip:/path/to/files/ /local/path/
我的2美分,在一个系统用户中,你可以在/etc/ssh/ssh_config上设置端口,然后rsync将使用这里设置的端口