This is a partial quote from http://www.linuxquestions.org/questions/linux-newbie-8/ssh-with-password-533684/ User: Brianetta
The way that does not require a password. You can use public/private key authentication instead of passwords with SSH. I’m going to assume that you’re using OpenSSH, which comes with practically every Linux distribution that there is.
[*:443ffa1dec] Configure your SSH server to accept private key logins. In /etc/ssh/sshd_config make sure that there’s a line that says PubkeyAuthentication yes (and that there is no # infront of it). If you change this file, you need to restart the sshd service. If you’re not sure, stop and ask somebody here before you break it.
[*:443ffa1dec] On your local machine (not the server), create yourself a pair of keys with ssh-keygen -t rsa (you can use other options than rsa, but I’m keeping it simple). Do not specify a password. Save the keys in the locations prompted.
[*:443ffa1dec] Open the contents of the id_rsa.pub file that you just created (it’s one very long line of text), and copy the contents into the end of the file $HOME/.ssh/authorized_keys on the server machine. Create the file if it doesn’t exist.
Now you should be able to ssh firstname.lastname@example.org without a password. If that works, you can use it in scripts, etc. Because you have a private key with no password to protect it, it’s important that you make sure that nobody gets their grubby hands on your id_rsa file. They can have the id_rsa.pub file (it’s public, you see) but the other one’s your precious.
If you think somebody has a copy of your id_rsa file, you can delete the line that you added to authorized_keys on the server, to disable that key.
Leave a Reply