Thursday, January 9, 2014

Automating scp,rysnc related tasks in linux using RSA key pairs





As i was using root for my use hence whatever task i am doing is for valid for root otherwise you have to use "/home/user/.ssh" directory for the same.

Here all steps i have performed machine from where i wanted to copy my files and remote machine is that  where i want to copy these files

Note: You have to take care for which user you want to set all these configurations.


Step 1
[root@server-sid /]# cd /root/.ssh

Step 2
[root@server-sid .ssh]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:

c0:54:02:7a:59:ec:35:55:50:6c:92:6a:7f:79:eb:88 root@FTI-376-VM-PXE-SRV.google.com

NOTE : Do not provide any password phrase for password for automatic login.

Step 3
[root@server-sid .ssh]#cat id_rsa.pub | ssh sid@192.168.119.28 'cat >> .ssh/authorized_keys'


And here you are ready to do things without remote machine password!

[root@server-sid ~]# scp -i id_rsa <file-to-be-transfer>  root@<remote-Server-IP/hostname>:/root/