linux服务器防止任何人使用su命令成为root用户
指定只有某个用户才可以使用su命令到root用户
实现方法:
1.vi /etc/pam.d/su
打开注释
# auth required pam_wheel.so use_uid
echo "SU_WHEEL_ONLY yes" >> /etc/login.defs
2.usermod  -G 10 lndy   //把lndy用户加入到wheel组
[root@localhost ~]# id landy
uid=500(lndy) gid=500(lndy) groups=500(lndy),10(wheel) context=root:system_r:unconfined_t:SystemLow-SystemHigh
[root@localhost ~]# id xxl
uid=501(xl) gid=501(xl) groups=501(xl) context=root:system_r:unconfined_t:SystemLow-SystemHigh
lndy用户可以su到root,而xl用户不可以su到root
[lndy@localhost ~]$ su -
Password:
[xl@localhost ~]$ su -
Password:
su: incorrect password