Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Linux Commands»Rsync Over a Non-Standard SSH Port: A Beginner’s Guide

    Rsync Over a Non-Standard SSH Port: A Beginner’s Guide

    By RahulMarch 20, 20163 Mins ReadUpdated:January 11, 2023

    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:

    1
    2
    # Syntax
    rsync -avz -e 'ssh -p [non-standard port number]' [source] [destination]

    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/ [email protected]:/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.

    commad file rsync SSH
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Sed Command to Delete Lines in a File

    Sed Command to Delete Lines in a File

    Sort Command in Linux with Practical Examples

    15 Practical Examples of Sed Command

    Sed Command in Linux with 15 Practical Examples

    View 2 Comments

    2 Comments

    1. Peter on March 22, 2016 1:44 pm

      After reading and understanding this, I realized moving the default port to >1024 was a bad idea:

      https://www.adayinthelifeof.nl/2012/03/12/why-putting-ssh-on-another-port-than-22-is-bad-idea

      Reply
      • Peter on March 22, 2016 1:45 pm

        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.

        Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Error: EACCES: permission denied, scandir (Resolved)
    • How To Install Python 3.11 on Ubuntu 22.04 / 20.04
    • How to Install Python 3.11 on Amazon Linux 2
    • An Introduction to the “./configure” Command: Compiling Source Code in Linux
    • How to Install PHP 8.x on Pop!_OS
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.