Tuesday January 1, 2008 20:48
Configure passwordless login in ssh
Posted by shakir as Information Insemination
This post is just a quick recap on how to configure passwordless ssh login.
In my setting, herugrim is my local machine, and anduril is the remote machine with the ip address of 192.168.1.10
The first step is to (optionally) generate RSA key for use with SSH. Make sure you dont use any passphrase for this or you’ll later need to enter the passphrase upon login instead of password, which doesn’t really server our purpose here.
shakir@herugrim ~ $ ssh-keygen -t rsa -C shakir@192.168.1.10 Generating public/private rsa key pair. Enter file in which to save the key (/home/shakir/.ssh/id_rsa): /home/shakir/.ssh/id_rsa.192.168.1.10 Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/shakir/.ssh/id_rsa.192.168.1.10. Your public key has been saved in /home/shakir/.ssh/id_rsa.192.168.1.10.pub. The key fingerprint is: 11:d9:23:2e:68:05:59:d9:ac:5a:00:69:17:3a:b4:24
Now we can copy the public key to the server. Instead of doing it manually, OpenSSH has a nice program to do just what we need:
shakir@herugrim ~ $ ssh-copy-id -i .ssh/id_rsa.192.168.1.10.pub shakir@192.168.1.10
So now lets test if our passwordless login is successful:
shakir@herugrim ~ $ ssh shakir@192.168.1.10 -i .ssh/id_rsa.192.168.1.10 shakir@anduril:~$
Great, it works
The next thing to do is to just make sure you keep your private key safe..
1 Response to Configure passwordless login in ssh
ummu
July 16th, 2009 at 12:19 pm
added notes: (actually to recap what I’ve learn)
“.ssh” is a hidden directory which is in /root or /home/user. you’ve to look inside the directory, and you’ll find the ‘known_host’ file, it stored all the public_key for all the pc that applied ssh to our pc.
to make people can ssh to pc A without password,
pc A generate key gen –#ssh-keygen
follow the instruction and you’ll find there are 2 more file in .ssh which is ‘id_rsa’(A’s private key) and ‘id_rsa.pub’(B’s public key)
pc B also have to generate key gen and have the keys
then, B pass it’s public key(only the key, not the file) to A and stored in A’s /.ssh/id_rsa.pub
Still in pc A : #cat id_rsa.pub > authorized_keys
// copy the keys and save it into file authorized keys
#service sshd restart
or in malay, klu comp A ada file /root/.ssh/authorized_keys, comp lain boleh masuk comp A tanpa pasword (comp. lain – comp. yg ada public key dlm authorized_keys)
this is for learning method using red hat, dont do harm to people!!