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

September 5, 2015 1.7k views

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.

2 Answers

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"

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.

Have another answer? Share your knowledge.