Question

Login to droplet with a password

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!


Submit an answer


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!

Sign In or Sign Up to Answer

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.

Bobby Iliev
Site Moderator
Site Moderator badge
April 10, 2025

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

KFSys
Site Moderator
Site Moderator badge
April 11, 2025

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.

alexdo
Site Moderator
Site Moderator badge
April 14, 2025

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

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

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.