Password-less SSH Setup In Linux


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
shashank@client’s password:
Now try logging into the machine, with “ssh ‘shashank@client'”, and check in:

.ssh/authorized_keys

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 🙂

Advertisements

6 thoughts on “Password-less SSH Setup In Linux

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s