How to create password-less SSH for Linux

Estimated Reading Time: 2 minutes

Sometimes you might need setting up Password-less SSH for running script or for application where you dont want to use password everytime. Here is a quick method to setup password-less SSH.

SSH_Dock_Icon_by_eternicode

Lab Scenerio:

Machine1: 192.168.160.194

Machine2: 192.168.160.197

a. Run this command on Machine1:

#ssh-keygen -t rsa

It will show you this output. Just press Enter throughout the queries asked.

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:

40:f0:87:19:23:47:1e:ef:65:7b:5d:05:b0:fa:48:81 root@puppet-server.test.com

The key’s randomart image is:

+–[ RSA 2048]—-+

| ooB …..|

| * B . . .|

| * E + . .|

| + o + . . |

| S + . . |

| . + |

| . . |

| |

| |

+—————–+

b. Let’s copy the key to remote Machine2:

#ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.160.197

root@192.168.160.197’s password:

It will show you the following output.

Now try logging into the machine, with “ssh ‘root@192.168.160.197′”, and check in:

.ssh/authorized_keys

to make sure we haven’t added extra keys that you weren’t expecting.

c. Now passwordless SSH is ready. Just test by typing this:

#ssh 192.168.160.197

Clap