Linux – Block All Users But One From SSH Access

linuxssh

I can currently login to my server via ssh as root. There may be some other users, however, that have ssh access. I want to block out any possible logins except from root. How can I do this?

Thanks.

Best Answer

So you can achieve your stated desire with the AllowUsers directive in your sshd_config file, for example:

$ grep AllowUsers /etc/ssh/sshd_config
AllowUsers root

However I would be wary of using the root account for ssh - consider instead an unprivileged account for normal use, using something like sudo to acquire root privileges only when needed.