Using SSH keys without entering a password
Thanks to my friend, Cade, and a number of websites, I was able to figure out how to ssh into my servers at home and work, without entering a password. Here’s how I did it:
1. From the box that you primarily work from, run ssh-keygen -t rsa -b 2048. From here, two keys are created: id_rsa and id_rsa.pub. The id_rsa is the private key that you will keep on your primary machine. The id_rsa.pub is what will be pushed to the servers you wish to connect to, without using a password.
2. Put id_rsa in your /home/user/.ssh directory on the primary machine and put id_rsa.pub on the server in /home/user/.ssh directory.
3. Rename id_rsa.pub to authorized_keys2 on the server. At this point, you should be able to connect from your primary machine without a password. It should be noted, however, that since the authorized+keys2 file under /home/user/.ssh, that you can only connect without a password as that user, not as root. If you wanted to do the same thing as root (which is not recommended, since we really shouldn’t ever connect to a box as root, without SUing), you’d simply put your authorized_keys2 file under /.ssh.
Note: Your authorized_keys2 needs to have permissions of 0600.
Special thanks to the following websites, which helped a great deal:
http://www.guyrutenberg.com/2007/10/05/ssh-keygen-tutorial-generating-rsa-and-dsa-keys/ has a good tutorial that takes you to the point of creating the private and public keys.
http://www.electrictoolbox.com/article/linux-unix-bsd/create-rsa-dsa-keys-ssh/
http://linux.byexamples.com/archives/297/how-to-ssh-without-password/