How to Sync Files/Directories Using Rsync with Non-standard SSH Port
Synchronization of Directories/Files with the help of Rsync with Non-standard SSH Port
rsync is a versatile, fast and powerful tool, which is used to sync and copy directories/files from local to remote or from remote to local hosts and vice-versa. Methods of Synchronizing files using rsync with non-standard SSH port are explained in this tutorial.
Modification of SSH Port to Non-standard Port
Open and edit the SSH configuration /etc/ssh/sshd_config file
[root@linuxhelp ~]# vim /etc/ssh/sshd_config
Uncomment and modify the port number. Here, we are changing the port number 22 to 15845.
[...] Port 15845 [...]
Save the file and close it.
Now you have to allow the new port through your router or firewall.
[root@linuxhelp ~]# firewall-cmd --permanent --add-port=15845/tcp success [root@linuxhelp ~]# firewall-cmd --reload Success
You have to upgrade selinux permissions to allow the port.
[root@linuxhelp ~]# semanage port -a -t ssh_port_t -p tcp 15845
Now restart SSH service
On SystemD
[root@linuxhelp ~]# systemctl restart sshd
On SysVinit
[root@linuxhelp ~]# service sshd restart
Synchronization of Rsync with non-standard SSH Port
Inorder to sync directories/files with the help of Rsync with non-standard ssh port, you have to execute the below command from the terminal.
SYNTAX:
# rsync -arvz -e ' ssh -p ' user@remote-server:/path/to/remote/folder /path/to/local/folder
Details of Remote System:
IP Address: 192.168.5.88
User name: root
Sync folder: /root/files
Details of Local System:
IP Address: 192.168.5.89
Sync folder: /root/backup
Synchronizing the contents of /root/files directories from remote server to /root/backup/ of my local system.
[root@linuxhelp ~]# rsync -arvz -e ' ssh -p 15845' root@192.168.5.88:/root/files /root/backup/
The authenticity of host ' [192.168.5.88]:15845 ([192.168.5.88]:15845)' can' t be established.
ECDSA key fingerprint is 03:b1:88:9e:3d:c6:eb:fe:38:6c:3f:90:06:51:4b:c9.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ' [192.168.5.88]:15845' (ECDSA) to the list of known hosts.
root@192.168.5.88' s password:
receiving incremental file list
files/
files/1
files/10
files/2
files/3
files/4
files/5
files/6
files/7
files/8
files/9
sent 205 bytes received 482 bytes 50.89 bytes/sec
total size is 0 speedup is 0.00
To verify the transferred files
[root@linuxhelp ~]# ls -l backup/files/
[root@linuxhelp ~]# cd backup
[root@linuxhelp ~]# ls -l files
total 0
-rw-r--r--. 1 root root 0 May 28 11:43 1
-rw-r--r--. 1 root root 0 May 28 11:43 10
-rw-r--r--. 1 root root 0 May 28 11:43 2
-rw-r--r--. 1 root root 0 May 28 11:43 3
-rw-r--r--. 1 root root 0 May 28 11:43 4
-rw-r--r--. 1 root root 0 May 28 11:43 5
-rw-r--r--. 1 root root 0 May 28 11:43 6
-rw-r--r--. 1 root root 0 May 28 11:43 7
-rw-r--r--. 1 root root 0 May 28 11:43 8
-rw-r--r--. 1 root root 0 May 28 11:43 9
Check the manual page to get more details about rsync command in linux.
[root@linuxhelp ~]# man rsync
Comments ( 0 )
No comments available