0% found this document useful (0 votes)
9 views

How to configure password less authentication using ssh

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

How to configure password less authentication using ssh

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

How to configure password less authentication using ssh

=====================================================

Login to node1.
Create a new ssh keygen .Here i have used RSA keygen. If you want you can use DSA
instead of RSA. By default rsa is generated. -t can be
specify to generate any other key like DSA

Test-Node1#ssh-keygen -t rsa
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 //.ssh/id_rsa. (private key)
Your public key has been saved in //.ssh/id_rsa.pub. (public key)
The key fingerprint is:
e4:34:90:01:7e:0a:38:45:fa:bb:4d:ef:0c:57:ce:2a root@node1

Go to the directory where the keys are stored. It will be stored in root�s home
directory by default.

Test-Node1#cd /root
Test-Node1#cd /.ssh
Test-Node1#ls -lrt
total 5
-rw------- 1 root root 887 Jul 29 23:03 id_rsa
-rw-r--r-- 1 root root 220 Jul 29 23:03 id_rsa.pub

Test-Node1#cat /etc/hosts
"/etc/hosts" [Read only] 6 lines, 88 characters
#
# Internet host table
#
::1 localhost
127.0.0.1 localhost
192.168.2.5 node1 loghost
192.168.2.6 node2

Login to node2 and perform the same what we have did for node1.

Test-Node2#ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (//.ssh/id_rsa):
Created directory '//.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in //.ssh/id_rsa.
Your public key has been saved in //.ssh/id_rsa.pub.
The key fingerprint is:
ad:14:b0:83:75:23:fa:c2:96:b6:1c:1d:85:96:b1:77 root@node2
Test-Node2#cat /etc/hosts
"/etc/hosts" [Read only] 6 lines, 88 characters
#
# Internet host table
#
::1 localhost
127.0.0.1 localhost
192.168.2.6 node2 loghost
192.168.2.5 node1
Now copy the id_rsa.pub key to node2 as authorized_keys where you want to login
without password. By doing this , you will login from node1 to node2 without
password.

Test-Node1#scp -r id_rsa.pub node2:/.ssh/authorized_keys


The authenticity of host 'node2 (192.168.2.6)' can't be established.
RSA key fingerprint is 93:cc:1f:07:17:bf:79:34:7e:05:2f:25:28:64:fb:60.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'node2,192.168.2.6' (RSA) to the list of known hosts.
Password:
id_rsa.pub 100% |*****************************| 220 00:00
Test-Node1#

In node2, copy the rsa key to node1 as authorized_keys. By doing this , You can
login from node2 to node1 without password.

Test-Node2#scp -r id_rsa.pub node1:/.ssh/authorized_keys


The authenticity of host 'node1 (192.168.2.5)' can't be established.
RSA key fingerprint is 93:cc:1f:07:17:bf:79:34:7e:05:2f:25:28:64:fb:60.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'node1,192.168.2.5' (RSA) to the list of known hosts.
Password:
id_rsa.pub 100% |*****************************| 220 00:00
Test-Node2#

Below command can also be used on node1 to copy the key to node2
#ssh-copy-id -i /root/.ssh/id_rsa.pub root@node2
root@node2's password: ( we need to provide root password of node2 )

========================
SNGPL Logs

cat authorized_keys >> /root/.ssh/authorized_keys


rm authorized_keys
exit
cd /root.ssh
cd /root/.ssh
ls
cd /
ssh-keygen -t rsa
cd /root/.ssh
ls
more authorized_keys
exit
ssh hoed01vm2
cat id_rsa.pub >> authorized_keys

You might also like