I have my digitalocean droplets setup so I can login to ssh via keyfiles. This works fine for the root account but if I create a secondary account via useradd, the only way I'm able to get into the account is via su. If I try to login with ssh using the same keyfile, I get:

Permission denied (publickey,gssapi-keyex,gssapi-with-mic) 

even though I added my public key to /home/user/.ssh/authorized_keys. What to do?

This is a CentOS 7 server.

Note: I also tried adding AllowUsers exampleuser root to /etc/ssh/sshd_config.

  • 2
    Check the logs on the server. – Michael Hampton Sep 5 '18 at 22:13
  • Did you restart the sshd service and then run ssh-keygen -t rsa and ssh-copy-id -i ~/.ssh/id_rsa.pub exampleuser@server as exampleuser? You can also connect with ssh -vvv to get more info on what's happening. – Nasir Riley Sep 5 '18 at 22:17
  • @NasirRiley All I had to do was restart sshd. Wasn't thinking about rehashing files. Thanks. If you put that in an answer, I'll accept it. – xendi Sep 5 '18 at 23:04

Be sure to restart sshd after you've made changes to /etc/ssh/sshd_config.

  • Also note: I had to change file permissions for ~/.ssh and ~/.ssh/authorized_keys. – xendi Sep 6 '18 at 9:29

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.