Linux – Why bother stopping ‘root’ from ssh login

linuxSecuritysudo

Best practice is to remove the ability of 'root' to login over ssh. However, I need to run some Ansible commands and am currently connecting via a user called "amdhske" and then have set this user up to not need to enter password to do sudo otherwise Ansible needs to keep the user's password hanging around.

So what is the point of disabling root access in this case? Any attacker who gets in to the "amdhske" user account over ssh can then sudo the heck out of the server. I am guessing the only advantage here is that by choosing a lengthy random username makes it highly unlikely an attacker would know about it whereas 'root' is the default username for, well, 'root'. Is there any other reason?

Best Answer

Pretty easy. Two reasons:

  1. You can limit what you can sudo with no password with your user. You just enter the proper configuration in sudoers files:

    amdhske ALL=NOPASSWD: /usr/bin/somecommand
    

If you login with root, then you have all the permissions to do anything.

  1. Every script kiddie on earth knows that your superuser account name is root. So what username do you think they are going to try to brute-force, etc to your system? Right, root.

That it is why is a good security practice to disable root ssh login.

Related Question