Wednesday, August 10, 2005

SSH keys - automatic login failure (still getting password prompt)

One of the coolest features of SSH, is its support for secure keys. You can create public and private keys, and then no password is required for login from a certain host, while still maintaining a secure connection.
This is very useful for scripts.

There are a million guides on the web how to do it .. (just Google "how to setup ssh keys") but they many fail to mention one thing! What to do if you created/updated the "authorized_keys" file and the authentication still fails ??

Well, it turns out that SSHd is very picky when it comes to permissions on the file. It will FAIL (!!) if the authorized_keys permissions are not 600, or the directory is not 755. So if you updated the authorized_keys file, and you still get a password prompt. Ensure that your permissions are set as follows:

$ chmod 755 $HOME/.ssh (or better yet, 700)
$ chmod 600 $HOME/.ssh/authorized_keys

And try again ..
Good luck!

No comments: