Network Topology
Tasks
** SSH Primary to Secondary Server without password
** Install rsync in both server
** Automate a directory to sync with Secondary server
SSH Primary to Secondary Server
without password
Login to Primary Server and check the IP address
Login to Secondary Server and check the IP address
From Primary Server create the SSH Key with
"ssh-keygen". Please do not provide any password to make it password
less.
Create .ssh directory in Secondary Server with below command.
# mkdir /root/.ssh/
Send the "id_rsa.pub" public key from Primary
Server to Secondary Server
# scp /root/.ssh/id_rsa.pub root@192.168.0.3:/root/.ssh
On Secondary Server create a file name
"authorized_keys" and put the content of "id_rsa.pub" on
that file
# touch /root/.ssh/authorized_keys
# cat /root/.ssh/id_rsa.pub >>
/root/.ssh/authorized_keys
Set permissions on Secondary Server
#chmod -R 700 /root/.ssh/
#chmod -R 640 /root/.ssh/authorized_keys
Now try to login from Primary Server to Secondary server
without password
# ssh 192.168.0.3
Install rsync in both server
On both server run following command to install rsync
# apt-get install rsync -y
Automate a directory to sync with
Secondary server
Let say I want to copy “/home/” directory from Primary
Server to Secondary server automatically every day at 1 AM.
Add the line below in /etc/crontab file
00 1 * * * root rsync -avzhe ssh /home/
192.168.0.3:/home/
Now restart cron Service
Enjoy!
No comments:
Post a Comment