• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Wednesday, May 21, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Linux

How to Sync Files/Directories Using Rsync with Non-standard SSH Port

How VPS by How VPS
November 2, 2018
in Linux, Operating System
0
0
SHARES
14
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Change SSH Port to Non-standard Port
  2. How to Rsync with non-standard SSH Port
    1. Syntax:
    2. Remote System Details:
    3. Local System Details:
      1. Sample Output
      2. Sample Output
      3. Sample Output
      4. Sample Output
  3. Conclusion

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.

How to Sync Files/Directories Using Rsync with Non-standard SSH Port

Rsync Files Over SSH Non-standard Port

So, It is mandatory to change your SSH default port number to something different which is very hard to guess. In such cases, how will you sync your files/folders with your Remote server? No worries, It is not that difficult. Here we will see how to sync files and folders using rsync with non-standard SSH 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:

# man rsync

Or refer our previous guide from the link below.

  1. Rsync: 10 Practical Examples of Rsync Command in Linux

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:

# 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.

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.

[...]
Port 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.

# firewall-cmd --add-port 1431/tcp
# firewall-cmd --add-port 1431/tcp --permanent

On RHEL/CentOS/Scientific Linux 6 and above, you should also update selinux permissions to allow the port.

# iptables -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 1431 -j ACCEPT
# semanage port -a -t ssh_port_t -p tcp 1431

Finally, restart SSH service to take effect the changes.

# systemctl restart sshd        [On SystemD]
OR
# service sshd restart          [On SysVinit]

Now let us see how to sync files using rsync with non-standard port.

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.

Syntax:
# rsync -arvz -e 'ssh -p <port-number>' --progress --delete [email protected]:/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: 192.168.1.103
User name: tecmint
Sync folder: /backup1

Local System Details:

Operating System: Ubuntu 14.04 Desktop
IP Address: 192.168.1.100
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 [email protected]:/backup1 /home/sk/backup2
Sample Output
[email protected]'s password: 
receiving incremental file list
backup1/
backup1/linux-headers-4.3.0-040300-generic_4.3.0-040300.201511020949_amd64.deb
        752,876 100%   13.30MB/s    0:00:00 (xfr#1, to-chk=2/4)
backup1/linux-headers-4.3.0-040300_4.3.0-040300.201511020949_all.deb
      9,676,510 100%   12.50MB/s    0:00:00 (xfr#2, to-chk=1/4)
backup1/linux-image-4.3.0-040300-generic_4.3.0-040300.201511020949_amd64.deb
     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
backup1

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
linux-headers-4.3.0-040300_4.3.0-040300.201511020949_all.deb            
linux-image-4.3.0-040300-generic_4.3.0-040300.201511020949_amd64.deb
linux-headers-4.3.0-040300-generic_4.3.0-040300.201511020949_amd64.deb

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

Conclusion

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.

Source: tecmint.com

Tags: Linux Commandslinux guidelinux vps setup guide
Previous Post

How to create Sudo users in CentOS 7

Next Post

Translate rwx Permissions into Octal Format in Linux

Next Post

Translate rwx Permissions into Octal Format in Linux

Leave a Reply Cancel reply

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

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet