Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ssh

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.

like image 232
Ketema Avatar asked Dec 28 '10 22:12

Ketema


People also ask

What port does rsync listen on?

Rsync is primarily a utility for synchronizing files between systems in an efficient manner and is frequently used for archival and backup purposes as well as data distribution and sharing tasks. Rsync also has the ability to operate in a daemon mode where it listens on port 873/TCP.

Does rsync use SSH config?

Rsync uses ssh to sync files between two machines and usually it will use default identity file present in ~/. ssh/ directory on Linux. In case you want to use a custom rsync file you can use -e or –rsh option of rsync.

How do I SCP to a different port?

By default, the SCP command uses the port 22 (SSH). In case the remote system has configured the SSH service to run on a different port, you still can use SCP followed by the -P flag to specify the port you need.


1 Answers

Your command line should look like this:

rsync -rvz -e 'ssh -p 2222' --progress ./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.

like image 129
klapa Avatar answered Nov 18 '22 10:11

klapa