Remote login without password
Suppose you have a login as ‘A’ in host ‘AA’ and another login ‘B’ in host ‘BB’ and you often have to switch between these logins with SSH. It feels irritating to give the password every time. There might also be situations when you need to run a shell script that manipulates the resources in the other login.
You can login using SSH without any password by doing this-
A@AA~$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/A/.ssh/id_rsa): <press enter > Enter passphrase (empty for no passphrase): <press enter >
Enter same passphrase again: <press enter >
Your identification has been saved in /home/A/.ssh/id_rsa.
Your public key has been saved in /home/A/.ssh/id_rsa.pub.
The key fingerprint is: 3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 A@AA
Then type this:
A@AA~$ ssh B@BB mkdir -p .ssh
password: <enter B’s password>
Then append the public key produced in .ssh/id_rsa.pub (in A) to .ssh/authorized_keys file in B.
This is done as follows:
A@AA~$ cat .ssh/id_rsa.pub | ssh B@BB ‘cat >> .ssh/authorized_keys’
password: <enter B’s password for the last time>
Now you login into B through ssh by just typing :
A@AA~$ ssh B@BB
B@BB~$
Thats it!
3 comments so far
Leave a reply

Very good da… Keep on posting like this.
I already thought of doing it…
I set it up as said, but when I ssh to the remote site, it indeed does not ask for the password but instead asking for the “pass phrase”. Did I miss anything here?
Hmm… if you had set a pass phrase while creating your key fingerprint using ssh-keygen it would ask for that phrase while you ssh to that remote host, instead of your password.
Also this pass phrase should be greater than 4 bytes in size.