SSH loging without password with RSA key

if you want to automate a backup task to different server and for that using a bash script one major hurdle is providing password for ssh session.</p>

to avoid this use RSA keys.

Log in to Server 1 with your user name  and generate a pair of authentication keys

[juned@nagios ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/juned/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/juned/.ssh/id_rsa.
Your public key has been saved in /home/juned/.ssh/id_rsa.pub.
The key fingerprint is:
dc:8c:ca:5b:b0:ac:ca:8b:26:f8:3b:cc:73:3e:40:2e juned@nagios.rims.com

Now use ssh to create a directory ~/.ssh on second server  (The directory may already exist, which is fine)

Finally append first servers new public key to second servers .ssh/authorized_keys

juned@nagios ~]$> cat .ssh/id_rsa.pub | ssh juned@nagios ~]$ 'cat >> .ssh/authorized_keys'

From now on you can log in to second server without password </div>

comments powered by Disqus