Linux Blog

No Password SSH Login

Filed under: Quick Linux Tutorials — TheLinuxBlog.com 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/id_rsa.pub >> .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.





Random Man Pages:
rain
QIntDict
kmem
hformat

2 Comments »

Comment by Maxim Yegorushkin

November 26, 2012 @ 7:12 am

Just use ssh-copy-id to automatically create .ssh/authorized_keys with the right permissions and copy the public key into it.

Pingback by The Linux Blog » AutoSSH

December 14, 2012 @ 9:15 am

[...] and man pages. If you want you can resume your SSH sessions without using a password, by using the no password SSH login technique. window._wp_rp_static_base_url = [...]

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>