After setting up SSH etc, ssh key not accepted and can't login.

After creating an SSH key and then creating a droplet (embedding the ssh key), I followed this tutorial on securing the droplet. But it ended up making it so the ssh key was rejected, after which I needed to destroy the droplet and start over.

Step five, where in file /etc/ssh/sshd_config you set PermitRootLogin no made it so the ssh key did not work.

Of course, I did go through this tutorial, which seems to setup a putty session to root user (“Auto-login username” set to root):

I should mention that overall Digital Ocean is great, and the tutorials are very helpful. But in my quest to make my server as secure as possible, these aspects of the tutorials are frustrating.

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

One of the tutorials shows how to create and save a putty session, to setup a putty session to root user (“Auto-login username” set to root).

If I change that saved putty session, or even create a new saved session, this time using a user other than root (though the user is part of the sudo group), then when I try to logon using that saved putty session, I get a message saying the server refused our key, and makes me logon with that other user.

after setting “PermitRootLogin no”, you should be logging in with the non-root user that has been created in step 2 this directive does not disable the key, it just disables remote root login, that means you have to have a standard user to login, and once on the server, switch to root account using “su”, or execute commands with root privilege using “sudo”