Monday, May 6, 2013

ssh keys RSA password-less authentication

Quick steps to implement password-less authentication.

Notes:
1. Below steps are for a home environment and hence passphrase is not used.
2. DSA is more secured than RSA.

-On source server - homeserver1

Login to the user account for which  password-less authentication needs to be set , in this case oracle user.


[oracle@homeserver1 .ssh]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_rsa):  ##Hit enter for keys to be placed at default location or mention desired path.
Enter passphrase (empty for no passphrase):  ##Recommended to use a passphrase
Enter same passphrase again:
Your identification has been saved in /home/oracle/.ssh/id_rsa.
Your public key has been saved in /home/oracle/.ssh/id_rsa.pub.
The key fingerprint is:
7b:34:24:c6:f6:76:ad:ea:79:aa:71:81:fd:e5:cd:44 oracle@homeserver1.oracle

## Public and private keys are generated in default path /home/oracle/.ssh

[oracle@homeserver1 .ssh]$ ls -ltr
-rw-r--r--  1 oracle oinstall 235 May  7 00:20 id_rsa.pub
-rw-------  1 oracle oinstall 887 May  7 00:20 id_rsa


-On destination server - homeserver2

Login to the user account for which  password-less authentication needs to be set , in this case oracle user.

Perform same steps as done on homeserver1.

Copy id_rsa.pub generated on homeserver1 as authorized_keys on homeserver2

[oracle@homeserver2 .ssh]$ ls -ltr
total 24
-rw-r--r--  1 oracle oinstall 235 May  7 00:21 id_rsa.pub
-rw-------  1 oracle oinstall 883 May  7 00:21 id_rsa
-rw-r--r--  1 oracle oinstall 235 May  7 00:22 authorized_keys

Similarly copy id_rsa.pub generated on  homeserver2 as authorized_keys on homeserver1.

[oracle@homeserver1 .ssh]$ ls -ltr
-rw-r--r--  1 oracle oinstall 235 May  7 00:21 id_rsa.pub
-rw-------  1 oracle oinstall 883 May  7 00:21 id_rsa
-rw-r--r--  1 oracle oinstall 235 May  7 00:22 authorized_keys

Test the connection both ways..

[oracle@homeserver2 .ssh]$ ssh oracle@homeserver1
Last login: Tue May  7 00:24:37 2013 from homeserver2.oracle
[oracle@homeserver1 ~]$ 

[oracle@homeserver1 .ssh]$ ssh oracle@homeserver2
Last login: Tue May  7 00:23:31 2013 from homeserver1.oracle
[oracle@homeserver2 ~]$


Hence works !

No comments:

Post a Comment