How to Sync Directories Using Rsync with Custom SSH Port

How to Sync Directories Using Rsync with Custom SSH Port

SSH default port is 22, every body knew it. And it will cause many brute force SSH attacks.

For security reasons, Linux administrator should change to custom port to securing SSH access to Unix server from brute force attacks.

How to change default SSH Port

Before change port number, first open firewall port to new SSH Port, example change to port 12345, to prevent locked your self because SSH port closed by firewall.

On RHEL, CentOS, and Scientific Linux 7, allow the new port through your firewall.

On RHEL/CentOS/Scientific Linux 6 and before, you should allow new SSH port with command below.

If you have Selinux enabled, you should run this command

Then Edit /etc/ssh/sshd_config and remark port 22 and add another port, for example 12345.

Then restart SSHD service using this command:

To connect SSH on custom port, use the following command

How to use Rsync on Custom Port

To use rsync on custom port from local directory to remote directory

Example you want to sync /home/website_dir to server 192.168.0.1

To use rsync on custom port from remote directory to local directory

Example you want to sync /home/website_dir on 192.168.0.1 to local directory

Hope this helps.

Leave a Reply

Your email address will not be published. Required fields are marked *