Setting up password-less SSH is quite an important thing to do. It saves us from entering the password everytime we need to login. A script that involves fetching details from multiple servers can be very annoying if we need to enter password for every single server there. Setting up password-less SSH before-hand is must.
Here’s how I did it (“how it is done” is more appropriate usage, but this blog is about what I learned, right? ;))
[shashank@server ~]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/shashank/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/shashank/.ssh/id_rsa.
Your public key has been saved in /home/shashank/.ssh/id_rsa.pub.
The key fingerprint is:
[shashank@server ~]$ ssh-copy-id shashank@client
Now try logging into the machine, with “ssh ‘shashank@client'”, and check in:
to make sure we haven’t added extra keys that you weren’t expecting.
Do this for all the servers & next time you need to execute a script on all your servers, you won’t need to enter password 🙂