How to revert to password login from ssh key login for root

Posted February 17, 2021 685 views
Ubuntu 18.04

Hello, I was working to add a new user on our droplet, and I accidentally disabled the root user ssh key login. Is there a way to revert back to password login for the root user? If I set PasswordAuthentication to yes in sshd_config and restart ssh, it still asks for the password for the SSH key when I login with root.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hello, @avebury

In order to enable the password level authentication, you need to set the PasswordAuthentication to yes in /etc/ssh/sshd_config

Once this is done you can restart the ssh service and give it another try. You can also check the value of PubkeyAuthentication in the sshd_config as well.

If you’re still getting the prompt the passphrase for your ssh-key you can make sure that you connect to the droplet without specifying the use of an ssh-key in your ssh client.

Also, the droplet default setting is the PasswordAuthentication in case you do not have any ssh-keys configured.

If you want to authenticate using an ssh-key you can disable the PasswordAuthentication by setting it to no and make sure that your ssh-key is also present in the ~/.ssh/authorized_keys file.


  • OK, thanks. I set PasswordAuthentication to no and that worked.

    Now it seems I need to re-do my ssh keys. Do I set my ssh keys for root and sudo users the same way? For instance:

    cat ~/.ssh/ | ssh root@remote_host "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys && chmod -R go= ~/.ssh && cat >> ~/.ssh/authorized_keys"


    cat ~/.ssh/ | ssh sudouser@remote_host "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys && chmod -R go= ~/.ssh && cat >> ~/.ssh/authorized_keys"


    • Hello there,

      You can also use the ssh-copy-id command to upload your public-key to the server’s authorized_keys file

      • ssh-copy-id username@

      Hope that this helps!