I'm trying to switch all of my servers to ssh key auth logins. I have it working with some servers but for what ever reason my new centos server is not working correctly.

I am on windows and using putty.

I have enabled key auth in the sshd_config and restarted it.

I also have denied root logins and created a new user that I can log in with using a password.

I am logging in to the server with that user, creating a .ssh folder in my ~ dir and then creating an authorized_keys file can copying in my key. I then chmod the .ssh dir 700 and then the file 640.

I try to log in and get a rejected key message and then the password entry.

What am I doing wrong?

Here is my sshd_config https://gist.github.com/alexhackney/64a4c99b993505a9e44f Here is the secure log https://gist.github.com/alexhackney/90319feb853e18a2fd48

I ran the tail on secure then logged in and out on another window and ran the command again.

  • 1
    first you need to give more information, log files and config – c4f4t0r Jan 26 '15 at 17:21
  • what log file do I need to look at? – ahackney Jan 26 '15 at 17:33
  • /var/log/secure for starters. Check your ${HOME}/.ssh/authorized_keys if it matches the key loaded in PuTTY. Check that the format is correct. – fuero Jan 26 '15 at 17:35
  • And this should be in the home for the user not root correct? – ahackney Jan 26 '15 at 17:45
  • When I check the secure log there is no entry about the key. – ahackney Jan 26 '15 at 18:11

Verify that the home directory of the new user is set to read/write for that user only (i.e. permission of 700). It's not enough for the .ssh directory to be 700 -- the home directory needs to be 700 too. Also, I don't think the argument to AuthorizedKeysFile needs the ~/ before .ssh/authorized_keys. My systems work fine without it.

  • The user directory is correctly set to 700 – ahackney Jan 26 '15 at 20:09
  • The ~ in the AuthorizedKeysFile directive was the problem. Thank you. – ahackney Jan 26 '15 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.