How VPS - How to use/setup VPS
  • 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
7
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
How VPS

How VPS

Related Posts

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

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

February 25, 2022
How to Install Apache Tomcat 8 on CentOS 7
Linux

How to Install Apache Tomcat 8 on CentOS 7?

February 11, 2020
Install Arch Linux With Btrfs Snapshotting
Uncategorized

Install Arch Linux With Btrfs Snapshotting

February 13, 2020
Next Post

Translate rwx Permissions into Octal Format in Linux

How to Find Out What Version of Linux You Are Running

How to Upgrade to Debian 7 (Wheezy)

Leave a Reply Cancel reply

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

Follow Us

  • 121 Followers
  • 87.2k Followers

Recommended

How to Install Mautic on CentOS 7

3 years ago

Installing HAProxy on Ubuntu 14.04

3 years ago

How to Setup Gunicorn to Serve Python Web Applications

3 years ago

How to Install Apache ActiveMQ on CentOS 7

3 years ago

Instagram

    Please install/update and activate JNews Instagram plugin.

Categories

  • 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

Topics

Apache Web Server Bluehost Review 2019 Bluehost Review 2020 Bluehost Review 2021 Centmin Mod CentminMod centos install htop fsck htop install HTTP DoS attack Install Snort on an Ubuntu install Zabbix on CentOS install Zabbix on CentOS 7 Linux Commands linux guide linux install htop linux vps setup guide MariaDB MariaDB Error Mysql mysqld error optimize MariaDB optimize Mysql snort Ubuntu
No Result
View All Result

Highlights

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Webmin Reviews

Virtualmin Reviews

CentOS Web Panel Reviews

Ajenti Reviews

ISPConfig Reviews

Trending

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

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

by How VPS
February 25, 2022
0

I tried to update some extensions by use yum on centOs which I specified in Dockerfile. After...

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
Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

February 17, 2020
Webmin Reviews

Webmin Reviews

February 17, 2020
How VPS – How to use/setup VPS

We bring you the best Premium WordPress Themes that perfect for news, magazine, personal blog, etc. Visit our landing page to see all features & demos.
LEARN MORE »

Recent News

  • 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”? November 17, 2020
  • How to optimize Mysql or MariaDB November 3, 2020

Categories

  • 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

[mc4wp_form]

© 2018 JNews - City News Magazine WordPress theme. All rights belong to their respective owners.
JNews is a top selling 2018 WordPress News, Blog, Newspaper & Magazine Theme.

No Result
View All Result
  • Home

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