I am building a script to automate and minimize access to root. I am going to try do it via SSH. I am currently having an issue using sed
to replace UID and GID 0 shell to /sbin/nologin
.
Why am I doing this? This disables root on login
, gdm
, kdm
, su
, ssh
, scp
, sftp
. I am trying to execute root privilege only via sudo
. If you know any suggestion on minimizing root access, please also suggest.
This is the current issue:
grep :0:0: /etc/passwd | sudo sed 's_/bin/bash_/sbin/nologin_' /etc/passwd
What is currently doing is replacing all /bin/bash
to /sbin/nologin
.
usermod --expiredate 1 root
? This should disable the root account.