rsync using ssh which is using customed port

Rsync is a common command that users and administrator alike uses it to synchronize files. The closest function that Microsoft uses is xcopy .

Objective :
Copy folder over to a path in a remote server or remote host.

Scope :

  1. remote server is using port 9876 for the ssh.
  2. IP of remote server 123.123.123.123.
  3. OS used on the remote host is linux based regardless redhat or debian.
  4. firewall is properly configured.

Usually we will use :

  1. Redhat :
    #rsync -avz –port=9876 /home/myfolder/mySrcFolder root@123.123.123.123:/home/myRemoteFolder/myTargetPath/
  2. Debian
    #sudo rsync -avz –port=9876 /home/myfolder/mySrcFolder root@123.123.123.123:/home/myRemoteFolder/myTargetPath/

Notice the difference, due to default security in debian such as ubuntu, you need to use sudo.

Unfortunately, the command above would not work. A better solution is :

#rsync -avz –rsh=’ssh -p9876′ /home/myfolder/mySrcFolder root@123.123.123.123:/home/myRemoteFolder/myTargetPath/

Or

#rsync -avz -e ‘ssh -p9876’ /home/myfolder/mySrcFolder root@123.123.123.123:/home/myRemoteFolder/myTargetPath/

Please take note that you are required to understand how rsync is used locally before attempting this recommendation.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.