SSH Authentication Using RSA Keys
January 12, 2009 by: Allen Sanford
If your daily routine involves accessing a remote linux server(s), you may have asked yourself how do I remember each password for each server, or I wish I could log-in to this system without a password. Well guess what you can fix it so you have the same password or better yet no password at all using RSA keys.
The first thing you need to do is make sure you have SSH and SSHD installed on the remote server. Second make sure that RSAAuthentication yes is set in your “/etc/ssh/sshd_config” and restart SSHD if you changed your configuration file.
# /etc/init.d/sshd restart
OK, now we are ready to setup your RSA keys. On your local machine (not the server) your notebook, desktop whatever computer you are most likely using now to read this you need to generate your Key Pair
# ssh-keygen -t rsa
Now you will be prompted for some information here follow the instructions as this can be different on different distros. When you get the question about a pass phrase you can just hit enter and you will not need to enter a password when SSHing into the system. This will generate a few files in your “~/.ssh” folder, the most important for what we are doing is id_rsa.pub. This file is the public half of your newly create RSA key pair, which we will need to upload to our server.
# scp ~/.ssh/id_rsa.pub <username>@example.com:~
Now that we have our key uploaded to the server we can login and finish the setup. Once you have SSHed into the server (the remote machine) you will need to concatenate the public key into the “~/.ssh/authorized_keys” file. If the ~/.ssh folder does not exists create it and then run the following.
# cat id_rsa.pub >> ~/.ssh/authorized_keys
You are now finish setting up your RSA keys and are ready to test by logging out and logging back into the remote machine.











