Rsync is a powerful and versatile tool for synchronizing files and directories between two different locations. By default, Rsync uses the SSH protocol to securely transfer data between systems. However, in some cases, you may need to use Rsync over a non-standard SSH port. This could be due to security concerns, network configurations, or other reasons.

Advertisement

This guide will walk you through the steps of using Rsync over a non-standard SSH port, including how to configure the remote server and the Rsync command line.

Using Rsync with Non-standard SSH Port

The next step is to configure Rsync to use the non-standard port. You can do this by using the “-e” option, which allows you to specify an alternate remote shell to use for communication.

The syntax for using Rsync with a non-standard SSH port is as follows:

For example, if you want to synchronize the directory “SRC” on your local machine to the remote server on port 2232, the command would be:

rsync -avz -e "ssh -p 2232" SRC/ user@remote.host:/DEST/ 

This command tells Rsync to use the “ssh -p 2222” command as the remote shell, which connects to the remote server on port 2222. The “-a” option stands for “archive” mode, which preserves the permissions, ownership, timestamps and so on. The “-v” option stands for verbose mode and will print messages that give you detailed information of the process, -e option tells rsync to use ssh as a remote shell, and -z compresses the data during transfer.

Rsync with Non-standard SSH Port
Rsync with Non-standard SSH Port

Configuring the Remote Server

You can configure the remote server to listen on a non-standard SSH port. To do this, you will need to edit the SSH server configuration file, typically located at /etc/ssh/sshd_config.

In the configuration file, locate the line that starts with “Port” and change the default port number (22) to the desired non-standard port number. For example, if you want to use port 2232, the line should read “Port 2232”.

Save the changes and exit the configuration file. Restart the SSH server for the changes to take effect.

Wrap Up

With the remote server and Rsync configured to use the non-standard SSH port, you can now run the Rsync command to synchronize the files and directories.

It’s important to note that if you are using firewall on the server and client side you may need to open the non-standard port for ssh and also for rsync.

And that’s it! By following these steps, you should now be able to use Rsync over a non-standard SSH port. This can be useful for increased security, or for when you need to work around network restrictions.

Share.

2 Comments

    • To clarify, I’m sure Rehul and other Tecadmin folks know this. It’s simply to inform other folks who come across this post in the future.


Exit mobile version