Linux Blog

No Password SSH Login

Filed under: Quick Linux Tutorials — at 1:28 am on Monday, November 26, 2012

I SSH a lot. In the past I’ve pretty much always typed passwords to log on, but when trying to SSH in using my phone, with a good password it’s a pain to say the least. I had SSH Keys setup with password-less login before but usually ended up losing the thumb drive the key was on or updating my system and forgetting to update the key. We won’t discuss the security or best practice here, that’s for another post.

Anyhow I assume you’re reading this post because you want to set up a no password SSH logon by using keys for whatever reason, this post outlines how to do it. (You can also use a pass phrase if you feel so inclined.)

First, you have to generate a key pair on the machine you wish to connect to:

~$ ssh-keygen

Don’t enter a pass phrase, and you can use the default path. Next, Create a authorized keys file on the machine,¬†allow your key and change permissions.

~$ touch .ssh/authorized_keys ~$ cat .ssh/ >> .ssh/authorized_keys ~$ chmod 600 .ssh/authorized_keys

Then, you need to carry id_rsa around with you, or alternatively you can SCP it to the host you wish to connect from. Some people choose to rename this file to identity, and keep it on a thumb drive. Make sure you change the permissions on the key to 600 and when logging in via ssh, you may use the -i option to specify your key if you renamed it, or don’t keep it in the .ssh/ directory. If you do, and everything is configured correctly, it should find it and login automatically. If it doesn’t work, you can check the server logs and¬† try the following to see if there is an issue with your key

ssh -i .ssh/id_rsa [user]@[host]

That’s pretty much all there is to it.