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!
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:
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
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
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
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.