我一直在尝试以下命令:

rsync -rvz --progress --remove-sent-files ./dir user@host:2222/path

SSH在端口2222上运行,但是rsync仍然尝试使用端口22,然后抱怨找不到路径,因为它当然不存在。

我想知道是否有可能在非标准的ssh端口上rsync到远程主机。


当前回答

使用“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/

其他回答

我在Mike Hike Hostetler的网站上找到了这个解决方案,它非常适合我。

# rsync -avz -e "ssh -p $portNumber" user@remoteip:/path/to/files/ /local/path/

有点跑题了,但也许能帮到别人。如果你需要传递密码和端口,我建议使用sshpass包。命令行命令看起来像这样: sshpass -p "password" rsync -avzh -e 'ssh -p PORT312' root@192.xx.xxx.xxx:/dir_on_host/

另一种选择,在你运行rsync的主机上,在ssh配置文件中设置端口,即:

cat ~/.ssh/config
Host host
    Port 2222

然后rsync将通过ssh与端口2222通信:

rsync -rvz --progress --remove-sent-files ./dir user@host:/path

使用“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/

我的2美分,在一个系统用户中,你可以在/etc/ssh/ssh_config上设置端口,然后rsync将使用这里设置的端口