Make the keys
Open up a terminal on your client machine and type “ssh-keygen -t rsa” for an RSA encrypted key. Either RSA or DSA should usually work. Don’t enter a passphrase and just hit enter until you get back to the shell. SSh-Keygen should tell you where the keys are. If you can’t find them, just add “-f ~/.ssh” at the end of the command and it will put them in the ~/.ssh directory.
Send the public key to the server
Switch to the directory where the keys are in: “cd ~/.ssh” and set the permissions for the private key to 600 while you’re at it: “chmod 600 id_rsa” or whatever your ID file is named, just leave the .pub alone for now.
“scp id_rsa.pub user@ssh-server.com:~/.ssh” You will have to enter your password, and the file will send.
Login to the server and add the key to authorized_keys
“ssh user@ssh-server.com”
Then change directories to ~/.ssh
“cd ~/.ssh”
Add the key:
“cat id_rsa.pub >> authorized keys”
Change permissions:
“chmod 640 authorized_keys”
Remove the key file:
“rm id_rsa.pub”
You may want to view your sshd_config to double check the name of the authorized_keys file if it doesn’t work, or ensure which encryption algorithms are enabled by viewing sshd_config. You might do it like this “sudo vi /etc/ssh/sshd_config”
Test it out
At this point you can log out of the server by typing exit.
You should now be able to log into the server without a password by using the private key. You can specify the key by passing the –i parameter to ssh. It might look something like this:
“ssh –i /home/dan/id_rsa dan@ssh-server.com”
