How to Copy using Rsync via SSH

Posted on

This article is written upon the purpose of using rsync which in several reference stands for remote sync although it can be actually used for synchronization between two different place or location in local PC or laptop. Sometimes, in the middle of the process to be able to copy files or folders using rsync, there is a need to encrypt the data in the forms of file or folders which is being transferred. In this case, it can be wrapped using an SSH remote secure connection.

Alternatively, it can also be done if in certain case, the service which is responsible for running rsync daemon or service on the counterpart or the machine where the files or folder is transferred does not active.  Although from a several point of view there are cases where each of the option is considered the best option to be executed :

a. Using native rsync protocol or rsync daemon which is served in default port 873.

It is a request either from a remote or local machine where the the request itself is passed to a machine runs an rsyncd or rsync daemon. Several aspects of using rsync request using the native port of rsync protocol is shown as follows :

1. It is used in local or intranet where the aspect of security is not becoming an issue. Another example for using rsync is where it is used to mirror public repository.

2. It is way faster than using SSH encryption because there is no overhead process triggered from the encryption done if the transfer process is encrypted using SSH protocol.


b. Using an SSH encrypted while executing rsync

It is a request from a remote machine to another machine where the request itself is encrypted via SSH remote connection. The following is the point which is needed to be look out for :

1. It is used when the security aspect is really becoming a consideration.

2. It is done across the public network such as internet where the actual target is not in the local or intranet.

3. The rsync daemon or service in the counterpart is not active.


Below is the actual pattern of using rsync over SSH remote connection :

rsync -avzP --append -e ssh source_location ""

For an instance below is shown as an example :

[root@hostname ~]# rsync -avzP --progress --append -e ssh /mnt/backup/server-image ""'s password:
sending incremental file list
^CKilled by signal 2.4.68kB/s   17:14:19

rsync error: unexplained error (code 255) at rsync.c(551) [sender=3.0.9]
[root@hostname ~]# 

As shown in the above output, the parameter has an additional parameter -e to execute a certain command which is the ‘ssh’ command. It is used to encrypt the transfer process using SSH encryption method.

Leave a Reply