can't login unless root

May 14, 2017 3k views
Getting Started Quickstart Security FAQ Deployment Ubuntu 16.04

I made a droplet with ssh keys selected, logged in as root perfectly fine, did "adduser demo" and "gpasswd -a demo sudo". When i try to ssh in as i get a "Permission denied (publickey)." but when i try again as its perfectly fine.

1 Answer
hansen May 14, 2017
Accepted Answer

Hi @CrustyWang69

You need to edit the file /etc/ssh/sshd_config and edit/add this line:

PasswordAuthentication yes

And restart sshd with the command sudo service ssh restart

  • @hansen thanks that worked but how do i login using ssh key? i can login with ssh key as root but have to use password as the other user?

    • Your sshd_config should now have these two lines (probably different positions)

      PasswordAuthentication yes
      PubkeyAuthentication yes

      First line allows passwords, second line allows keys.

    • @hansen nvm i figured it out apparently you need to add the key again loggin in as new user like so "ssh-copy-id newuser@host" the ssh key you use at droplet creation is for root only apparently

      • @CrustyWang69

        Ahhh, sorry, I misunderstood your question then. I thought that you wanted to be able to login with password. Someone just asked that question a few minutes before.

        I would highly recommend only using keys and disabling the password access for all users.

Have another answer? Share your knowledge.