Passwordless SSH

1. Generate public and private keys using ssh-key-gen

[root@localhost .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/
The key fingerprint is:
7c:a8:e5:63:4c:f0:77:4c:e4:b1:b4:7f:16:91:73:2b root@localhost.localdomain
The key’s randomart image is:
+–[ RSA 2048]—-+
| + ..|
| + + oo|
| . = .+|
| + . o E ..|
| S o o o o|
| * o . o |
| . = |
| . . |
| |

2. Copy the generated local machine’s public key to remote-host using ssh-copy-id
ssh-copy-id command will append the keys to the remote-host’s .ssh/authorized_key.

[root@localhost .ssh]# ssh-copy-id -i ~/.ssh/
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed — if you are prompted now it is to install the new keys
root@’s password:

Number of key(s) added: 1

Now try logging into the machine, with: “ssh ‘’”
and check to make sure that only the key(s) you wanted were added.

3. Login to remote machine using ssh without issuing password

[root@localhost .ssh]# ssh
Last login: Tue Oct 11 15:55:44 2016 from root


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s