Janux — Blog

December 21, 2007

How to SSH login without password … a+b+c.

Filed under: Gnu/Linux, Work — janux @ 11:36 am

host a = hestia = Origin
host b = balder = Destination

In host a and with a normal user NOT root:
[janux@hestia ~]$ cd
[janux@hestia ~]$ cd .ssh/ ( Create this directory if not exist mkdir .ssh )
[janux@hestia .ssh]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/janux/.ssh/id_rsa): id_rsa_host_b
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_rsa_host_b
Your public key has been saved in id_rsa_host_b.pub.
The key fingerprint is:
1e:35:4f:fa:56:86:bb:9a:42:a5:17:e9:1c:ce:00:89 janux@hestia.linuxcabal.org


If the .ssh directory do not exist in host b we must create it !!

[janux@hestia .ssh]$ ssh janux@host_b mkdir -p .ssh

TYPE YOUR USER PASSWORD

[janux@hestia .ssh]$ ssh janux@host_b chmod 700 .ssh
TYPE YOUR USER PASSWORD

[janux@hestia .ssh]$ cat .ssh/id_rsa_bak.pub | ssh janux@host_b ‘cat >> .ssh/authorized_keys’
TYPE YOUR USER PASSWORD

[janux@hestia .ssh]$ ssh janux@192.168.107.6 chmod 600 .ssh/authorized_keys
TYPE YOUR USER PASSWORD

Now in host B go like R00T go and uncomment this lines in /etc/ssh/sshd_config

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

Restart sshd service

NOW Go to host a and type:

[janux@hestia .ssh]$ ssh janux@host_ b
[janux@balder ~]$

What if you got more than one server … EASY: Do exactly the same and add an extra ssh key just like this:

[janux@hestia .ssh]$ ssh-add id_rsa_NEWSERVER

And continue comping the PUB key to the host b just like we did before.

NOTE: Do not forget to change the file attributes 600 and 700 is is very important.

DONE !!

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by WordPress