Using rsync is a very nice method to syncronize backups or other files between two machines. One thing that causes people a bit of headache is however how to do that when not using the standard port 22 for ssh.

One reason for people to change ssh to a non-standard port is that we are currently internet-wide experiencing a rise in botnets knocking on this port, attempting several default usernames and passwords. A really easy way of fending that off is to move ssh to a different port number. Any port would do but then there are a number of things that may break.

The rsync is one of them. In the manual for rsync it is stipulated that the port number can be inserted in the URL specification such as:

rsync -a /source user@host.name:77/mnt/disk/destination

But this does not seem to work. The best way is instead to pass the port parameter directly to ssh by using the rsync -e directive such as this:

rsync -a -e "ssh -p77" /source user@host.name:/mnt/disk/destination

This works like a charm for most things. One more note, the rsync directive –port=port is a listen port and wont work as a destination port in this case.