By lindahl22
I would like to have a secure Ubuntu server. I believe the best way to accomplish this is to only use SSH keys and disable use of the root user account. Accomplishing this is not made easy. The tutorials either show you how to use SSH keys on root or how to use a second account with a password, not a combination of the two. I have tried to do both and failed. The following is what I have attempted to do to accomplish this task.
Create Ubuntu droplet with SSH keys in DO panel. Login to root using SSH key and create secondary user. Paste the SSH key into the secondary users’ ~/.ssh/authorized_keys file. Either disable root login or require SSH keys: PermitRootLogin No || without-password <— which one do I choose here?? Kill the ‘/usr/sbin/sshd -D’ process reload ssh
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 directions were very helpful to me - but I still was not able to ssh in as the non-root user. My issue (that others may have experienced) was that I copy/pasted my public key into the authorized_keys file - and that paste included splitting the line. One way to see if you have this issue is to run the command wc -l /home/newuser/.ssh/authorized_keys and the response should be 1. In my case it was 5. So I edited the file to remove the line-breaks, saved it, restarted ssh - and all was well. Hope this helps.
I am having a similar problem. My key works when login in for root but not for non-root users.
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.