Linux – Disabling root login with ssh didn’t work

linuxSecuritysshUbuntu

I recently disabled root login via ssh on my ubunutu server as I was getting quite a lot of ssh attempts with root. I did this by editing the /etc/ssh/sshd_config file and restarting ssh.

However, when I recently checked my log file again, I saw there were numerous other attempts with root in there? – The log message was "failed password" – but if this did work, why would it simply not fail at the first hurdle and say "failed – root login disallowed" or something similar?

Is there a way to tell whether I have configured this correctly?

Best Answer

I assume you set the PermitRootLogin to no. If this is the case, SSH will still accept the connection but then deny root login. You will see this in the logs but it will not permit root to login.

I also use the "without-password" option to permit root login only with SSH keys.

I've not dug into it but suspect this is because SSH accepts the connection and then hands the authentication process to PAM.

If you wish to block these attempts, fail2ban is a popular tool for this purpose.

http://www.fail2ban.org/wiki/index.php/Main_Page

Personally, I am not a fan of these log analyzers but they have their place.

Related Topic