Step by step instructions to Sync Data between 2 Servers Automatically

In this article I will disclose how to arrangement 2 Linux workers to consequently ad information between a particular catalog on every worker. To do this we will utilize rsync, Ssh key verification, and a cron work.

We should call the 2 workers ‘SOURCESERVER’ and ‘DESTSERVER’ for

SOURCESERVER = Source worker the worker we are interfacing from to transfer the information

DESTSERVER = Destination worker the worker we are interfacing with get the information

Section 1 – Setting up SSH key confirmation

To begin with, we need to ensure the DESTSERVER can utilize key confirmation empowered. Discover your sshd arrangement record typically ‘/and so on/ssh/sshd_config’ and empower the accompanying choices on the off chance that they are not previously set.

RSAAuthentication yes

PubkeyAuthentication yes

AuthorizedKeysFile .ssh/authorized_keys

In the event that you alter the document make certain to restart sshd subsequently.

#/and so forth/init.d/sshd restart

Then, on the SOURCESERVER we will make people in general/private key pair to be utilized for verification with the accompanying order.

# ssh-keygen – t rsa

*Note: Do not enter a passphrase for this, hit enter when incited.

This ought to make 2 records, a public key document and a private key document.

The public key record normally [homedir]/.ssh/id_rsa.pub we will transfer to the DESTSERVER.

The private key document normally [homedir]/.ssh/id_rsa we will keep on the SOURCESERVER.

*Be sure to keep this hidden key safe. With it anybody will actually want to interface with the DESTSERVER that contains the public key.

Presently we will plant the public key we made on to the DESTSERVER.

Pick the client account which you will use to associate with on SSH Client, we will call this client ‘destuser’ for the present.

In that record’s home registry, make an ‘.ssh’ subdirectory, and in that index make another content document called ‘authorized_keys’. In the event that it as of now exists, incredible, utilize the current document.

Open the ‘authorized_keys’ record and glue in the substance of the public key you made in the past advance id_rsa.pub. It should look something like the accompanying

ssh-rsa sourceuser@SOURCESERVER

Save the record and change the authorizations to 600 for the document and 700 for the ‘.ssh’ catalog.

Presently to test that the keys are working.

From the SOURCESERVER have a go at signing in as should be expected utilizing ssh to the DESTSERVER.