How To Use Rsync Over Ssh In A Secure Manner?


Rsync is very popular synchronization tool used in Linux environment. Rsync communication is clear text by default. This makes rsync vulnerable man in the middle attacks. How can we make rsync secure with ssh . In this tutorial we will look different ways to make secure with ssh

Check Ssh Connection

The first thing we will do is checking the remote ssh service. We will of course use ssh command for this. In this example the user is root and server name is poftut2 .

Copy Single File From Local To Remote Via Ssh Tunnel

The first example is about copying local single local file to remote system via ssh. We will provide -e ssh parameter to enable ssh tunelling.

Enable PasswordlessKey Based Ssh Authentication

In order to make things simpler and work as batch we should setup passwordless key based ssh authentication. This is done by copying and setting login public key to the remote systems. First we will create ssh kek.

This will create a private and related public key pair in ~/.ssh/ directory. Now we will setup key based authentication with the following command. The username will be ismail and remote system is poftut2

Copy Single File From Remote To Local Via Ssh Tunnel

In this example we will copy remote file named to the local directory /root/ . . is used to specify current working directory. The local file will be named .

LEARN MORE  How To Login To Linux with Passwordless via SSH with Key Based Authentication?

Synchronize From Local Folder To Remote Folder

Now we need more useful examples. One of the most used situation is synchronizing local folder to the remote folder. We will synchronize from local folder to remote folder via ssh tunnel.

Synchronize From Remote Folder To Local Folder

This example is the reverse version of previous example. We will synchronize from remote system to the local system.

Specify Different Ssh Port

Ssh uses TCP/22 as default port. But this may not the same for some times. We may need to specify the remote ssh port explicitly. We can use -e option with ssh command like below.

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)