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:
If you need to switch back to the root user, the best approach is to use:
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:
And if needed, update the SSH config to allow password auth as per the guide above:
Then 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:
Regards