Report this

What is the reason for this report?

Login to droplet with a password

Posted on April 9, 2025

Hello, I am creating a droplet using Terraform. For authenticating to the VM, I am using SSH keys. Its working fine, but when I switch between users and want to log back as root user, its asking for a password. What password do I use, as there was no root password set during droplet creation? Thanks in advance!



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

Hey @JaiminJoshi 👋

When you create a Droplet with SSH keys, password authentication is disabled by default I believe:

https://docs.digitalocean.com/support/i-lost-the-ssh-key-for-my-droplet/#enable-password-authentication

If you need to switch back to the root user, the best approach is to use:

sudo -i

from your regular user, if it has sudo privileges.

If you really need to enable password login or set a root password (not recommended for security reasons), you can SSH into the Droplet and run:

sudo passwd root

And if needed, update the SSH config to allow password auth as per the guide above:

sudo nano /etc/ssh/sshd_config
# Set:
PasswordAuthentication yes

Then restart SSH:

sudo systemctl restart ssh

But again, try to stick with SSH keys and sudo for better security!

- Bobby

Heya,

You’ll need to turn on PasswordAuthentication in your sshd_config first. By default the root password is not known so you need to change it beforehand and use the one you’ve changed it to.

Heya, @jaiminjoshi

If the droplet was created with SSH key, than the password authentication will be disabled and you’ll need to enable it as described and then restart ssh:

sudo nano /etc/ssh/sshd_config
# Set:
PasswordAuthentication yes

Regards

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.