Change SSH Port to Non-standard Port

To do this, open and edit the SSH configuration /etc/ssh/sshd_config file:

# vi /etc/ssh/sshd_config
Find the following line. Uncomment and change the port number of your choice. 
I recommend you to choose any number which is very hard to guess.
In RPM based systems such as RHEL, CentOS, and Scientific Linux 7, you need to allow the new port through your firewall or router.
Finally, restart SSH service to take effect the changes.

How to Rsync with non-standard SSH Port

Run the following command from the terminal to sync files/folders using Rsync with non-standard ssh port.

# rsync -arvz -e 'ssh -p <port-number>' --progress --delete user@remote-server:/path/to/remote/folder /path/to/local/folder

For the purpose of this tutorial, I will be using two systems.

Remote System Details:

IP Address:
User name: tecmint
Sync folder: /backup1

Local System Details:

Operating System: Ubuntu 14.04 Desktop
IP Address:
Sync folder: /home/sk/backup2

Let us sync the contents of remote server’s /backup1 folder to my local system’s folder /home/sk/backup2/.

$ sudo rsync -arvz -e 'ssh -p 1431' --progress --delete tecmint@ /home/sk/backup2
Sample Output
tecmint@'s password: 
receiving incremental file list
        752,876 100%   13.30MB/s    0:00:00 (xfr#1, to-chk=2/4)
      9,676,510 100%   12.50MB/s    0:00:00 (xfr#2, to-chk=1/4)
     56,563,302 100%   11.26MB/s    0:00:04 (xfr#3, to-chk=0/4)

sent 85 bytes  received 66,979,455 bytes  7,050,477.89 bytes/sec
total size is 66,992,688  speedup is 1.00.

Let us check the contents of /backup1/ folder in the remote server.

$ sudo ls -l /backup1/
Sample Output
total 65428
-rw-r--r-- 1 root root  9676510 Dec  9 13:44 linux-headers-4.3.0-040300_4.3.0-040300.201511020949_all.deb
-rw-r--r-- 1 root root   752876 Dec  9 13:44 linux-headers-4.3.0-040300-generic_4.3.0-040300.201511020949_amd64.deb
-rw-r--r-- 1 root root 56563302 Dec  9 13:44 linux-image-4.3.0-040300-generic_4.3.0-040300.201511020949_amd64.deb

Now, let us check the contents of /backup2/ folder of local system.

$ ls /home/sk/backup2/
Sample Output

As you see in the above output, the contents of /backup1/ have been successfully copied to my local system’s /home/sk/backup2/ directory.

Verify /backup1/ folder contents:

$ ls /home/sk/backup2/backup1/
Sample Output

See, both remote and local system’s folders have same files.


Syncing files/folders using Rsync with SSH is not only easy, but also fast and secure method. If you’re behind a firewall that restricts port 22, no worries. Just change the default port and sync files like a pro