Is it possible to specify a different ssh port when using rsync?

I have been attempting the following command:

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

SSH is running on port 2222, but rsync still tries to use port 22 and then complains about not finding the path, cause of course it does not exist.

I would like to know if it is possible to rsync to a remote host on a non-standard ssh port.


Your command line should look like this:

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

this works fine - I use it all the time without needing any new firewall rules - just note the SSH command itself is enclosed in quotes.


Another option, in the host you run rsync from, set the port in the ssh config file, ie:

cat ~/.ssh/config
Host host
    Port 2222

Then rsync over ssh will talk to port 2222:

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

when you need to send files through a specific SSH port:

rsync -azP -e "ssh -p PORT_NUMBER" source destination

example

rsync -azP -e "ssh -p 2121" /path/to/files/source user@remoteip:/path/to/files/destination
链接地址: http://www.djcxy.com/p/60040.html

上一篇: rsync文件作为用户使用ssh密钥

下一篇: 使用rsync时可以指定不同的ssh端口吗?