Thursday, August 1, 2013

SSH Passwordless login

This is tested on RHEL-6

run the following command to generate the public key and copy it over to the system where you want to login without password.

[root@RHEL-6 .ssh]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
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:
ea:86:92:04:ac:35:21:e8:bf:9d:3c:72:26:f4:46:3a root@RHEL-6
The key's randomart image is:
+--[ RSA 2048]----+
|.                |
|o .              |
|o. .             |
|.oo              |
|.o..    S        |
|. .o . .         |
| ...B.o          |
|  oE.@.          |
|   .B.o          |
+-----------------+
[root@RHEL-6 .ssh]# ll

type in the following command now :

ssh-copy-id -i ~/.ssh/id_rsa.pub  rsangvik@cluster1

You would get the following message: And the  .ssh/authorized_keys is created automatically with th command

Now try logging into the machine, with "ssh 'rsangvik@cluster1'", and check in:

  .ssh/authorized_keys

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

[root@RHEL-6 .ssh]# ssh rsangvik@cluster1

See the prompt:

Last login: Thu Aug  1 10:25:28 2013 from rhel-6.example.com
-bash-3.2$ hostname
cluster1




No comments: