Home Miscellaneous How to do Rsync with a non-standard ssh port ?

How to do Rsync with a non-standard ssh port ?

by SupportPRO Admin

Rsync is a powerful and widely used tool for copying and synchronizing files between servers. It is commonly used by system administrators because it is fast, secure, and reliable. By default, rsync connects to remote servers using SSH on port 22. However, many servers are configured to use a non-standard SSH port for better security.

In such cases, rsync can still be used without any issues by specifying the custom SSH port in the command.

Why Use a Non-Standard SSH Port

Many administrators change the default SSH port to reduce unauthorized access and automated attacks. When a server uses a custom port, tools that rely on SSH must be told which port to use. Rsync supports this easily through command-line options, allowing secure file transfers without changing server configurations.

Rsync Command with a Non-Standard SSH Port

To use rsync with a custom SSH port, you need to specify the port using the -e option. This option tells rsync which remote shell command to use.

Example command:

rsync -avz -e “ssh -p $portNumber” user@destinationserverIP:/filespath /path_to_local/

Replace PORT with the actual SSH port number, such as 2222.
This command securely connects to the remote server and copies files to the local system while preserving permissions and directory structure.

How the Command Works

  • -a enables archive mode to preserve file attributes

  • -v provides detailed output during the transfer

  • -z compresses data to improve transfer speed

  • -e “ssh -p PORT” specifies the custom SSH port

Once the correct port is provided, rsync behaves exactly like a standard transfer.

Benefits of Using Rsync with a Custom Port

Using rsync with a non-standard SSH port allows administrators to follow existing security policies without limiting functionality. File transfers remain encrypted, efficient, and reliable. Rsync continues to support incremental transfers, meaning only changed files are copied, which saves time and bandwidth.

Common Use Cases

  • Server-to-server file synchronization

  • Secure backups over SSH

  • Website or application data migration

  • Remote log or data transfer

Conclusion

Rsync works seamlessly with non-standard SSH ports when the correct options are used. By specifying the SSH port directly in the command, administrators can securely synchronize files without modifying SSH configuration files. This makes rsync a flexible and trusted solution for secure file transfers across different server environments.

If you need assistance configuring or running rsync commands, SupportPRO Server Admin is available to help with expert server support.

Server not running properly? Get A FREE Server Checkup By Expert Server Admins - $125 Value

Leave a Comment