How to disable root login on console on debian and cent os 6. I have tried truncating /etc/securetty but it will disable all the users. I want to disable only root login through console.
3 Answers
This will disable the root account on debian (not sure about cent os):
sudo passwd -l root
-
might as well add this answer (the accepted one) from serverfault with setting /bin/false as shell for root (it's an OS agnostic solution). Not the part about ssh.hyph– hyph2017-03-10 12:44:24 +00:00Commented Mar 10, 2017 at 12:44
1) Activate the pam_access module on /etc/pam.d/login adding on the first 'account' line --> "account required pam_access.so"
2) Configure the access on /etc/security/access.conf :
3) +:root:cron crond [To avoid " pam_access(crond:account): access denied for user root' fromcron'" and "crontab: pam_access(crond:account): access denied for user root' fromcron'"]
-:root:LOCAL
You could also edit the /etc/passwd file. Change the /bin/bash at the end of the "root-line" to /bin/false or /usr/sbin/nologin.
suorsudo?