For many people ssh-ing into other machines seems to be a daily(and dirty) task. Its hard to type in passwords every time. So this is what I did to avoid typing passwords for ssh(yes i am lazy)
Lets call the machine you are connecting from as “home” with your user name “irfana” and the machine you are connecting to as “server” with your user name as “remote”. Please note that in case the account in your “home” computer is compromised, the attacker can effectively login to the “server” as well. So use this carefully,there is a security risk.
####General Method(if you are super lazy goto #Alternative Method below)
First you have to generate an RSA public-key, private-key pair. The public key will be placed in the server computer so that it can identify your computer when you ssh to it.To generate this key pair is open a terminal in “home” and type:
Next you have to store the public-key in “/home/irfana/.ssh/id_rsa.pub” to “server”. For this first create a directory on “server” by ssh-ing to it: (don’t worry if the directory is already there):
Next copy the public key from “home” to “server”
Now you are done. Try ssh-ing to the server and you will be directly greeted with a prompt:
The above method is a general solution for password less SSH ,but here is a simple one liner that will do the same trick. Just type in the server password twice when the terminal asks.
Also remember that
1)The use of keys identifies your “home” computer to the “server”, so in case your account in “home” is compromised, immediately delete the corresponding key from .ssh/authorized_keys at the “server”. 2)You have to do this every time you install a new OS in “server” or “home”. 3)I have only tested this on the machines that I use (CentOS 6)… but this should work well in Fedora, Ubuntu,Suse and Mac.
Thanks for being patient and reading this post,for any suggestion or question please comment below.