Today, we will be discussing about how to sync files using rsync with non-standard SSH port. You might wonder why do we need to use non-standard SSH port? It is because of security reasons. Everybody knows 22 is the SSH default port.
As you might know, rsync, also known as Remote Sync, is a fast, versatile, and powerful tool that can be used to copy and sync files/directories from local to local, or local to remote hosts. For more details about rsync, check man pages:
Or refer our previous guide from the link below.
Change SSH Port to Non-standard Port
As we all know, By default rsync uses default SSH port 22 to sync files over local to remote hosts and vice versa. We should change our remote server’s SSH port to tighten the security.
To do this, open and edit the SSH configuration /etc/ssh/sshd_config file:
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.
Make sure you are using a unique number which is not used by existing services. Check this netstat article to know which services are running on which TCP/UDP ports.
For example, here I use port number 1431.
Save and close the file.
In RPM based systems such as RHEL, CentOS, and Scientific Linux 7, you need to allow the new port through your firewall or router.
On RHEL/CentOS/Scientific Linux 6 and above, you should also update selinux permissions to allow the port.
Finally, restart SSH service to take effect the changes.
No comments:
Post a Comment