Sshd_config still allowing password authentication
Solution 1:
You need to do three things here:
(1) Set PermitRootLogin
to be without-password
or restrict-password
or no
. For security. I normally set it to no
.
(2) You're missing something else that's pretty important. You should be using PAM for authentication for things - UsePAM yes
is what the default usually is; this allows you to use UNIX user login data.
(3) Also important, NORMALLY you set ChallengeResponseAuthentication
to no
. This protects from bypassing the without-password
restriction for root
logon. (The exception is if you're using libpam-duo
and the Duo Security 2FA system, in which case you need ChallengeResponseAuthentication
set to yes
, but this isn't a typical setup.)
Once you've done that, sudo service ssh restart
to restart the SSH service with the new configuration. Attempt SSH from another window before you logout of your SSH session to make sure things are working as expected.
Solution 2:
I followed Thomas' steps but still didn't work. Turns out I just needed to set UsePAM
to no
and it now disallows login without a public key.