Linux Setting rsync to use a different port number

So you have tightened security on your main server by changing the default port number.

Once a week to backup your server data by using the rsync application on a local backup server – possibly even running a crontab script.

All of a sudden you get errors such as:


ssh: connect to host port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-24.1/rsync/io.c(359)

Why is this ???

The option rsh allows the desired port to be specified through ssh.

In the following example, the -r option specifies ‘recursive’; -z enables compression; –rsh=’ssh -p1234′ tells rsync to use port number 1234 for transfers/connection.

The code would look something like this:


rsync -r -z --rsh='ssh -p1234' /dir1 maybe@me.my.my.domain:/rdir --progress --stats

That’s it enjoy

Advertisements

One thought on “Linux Setting rsync to use a different port number

Post a comment

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s