Question

How do I disable access to my server via a root password?

Hi.

I setup my droplet on my iMac and I used a ssh key to access the server. I then created a separate ssh key for my laptop, but when I tried to access the server with the new key, it asked me for the root users password. Why is this? How do I disable password access to my server? I don’t even want a password for the root is this possible?


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.

Ryan Quinn
DigitalOcean Employee
DigitalOcean Employee badge
March 17, 2016
Accepted Answer

That setting is controlled by the PasswordAuthentication directive in /etc/ssh/sshd_config setting this to “no” will disable password authentication on ssh. If you are being prompted on your second computer for a password I would double-check your configuration and make sure you can log in with your new key before turning off password authentication. SSH will attempt key based authentication before prompting for a password.

I finally got this working. As @ryanpq said you have to set PasswordAuthentication to no. But doing this alone didn’t work for me. Every-time I tried to log into my server from my desktop without using a password, I would get the permission denied (public key) error.

To fix this I had to manually add my public key to /.ssh/authorized_keys on my server. For some reason the key I added on the settings page for my droplet was not being used.

Now when I log into my server from my desktop I have to use the public key. I can’t log into my server from my laptop because I haven’t added a key to that machine yet. This is exactly what I wanted.

Don’t forget to restart ssh! I had to use command: sudo systemctl restart ssh

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.