auth required pam_wheel.so use_id
[liwm@riyimei ~]$ cat /etc/pam.d/su
#%PAM-1.0
auth sufficient pam_rootok.so
# Uncomment the following line to implicitly trust users in the "wheel" group.
#auth sufficient pam_wheel.so trust use_uid
# Uncomment the following line to require a user to be in the "wheel" group.
#auth required pam_wheel.so use_uid
auth substack system-auth
auth include postlogin
account sufficient pam_succeed_if.so uid = 0 use_uid quiet
account include system-auth
password include system-auth
session include system-auth
session include postlogin
session optional pam_xauth.so
auth required pam_wheel.so use_id
[liwm@riyimei ~]$ su -
Password:
su: Permission denied
[liwm@riyimei ~]$ exit
logout
[root@riyimei ~]# usermod -G wheel liwm
[root@riyimei ~]# su - liwm
Last login: Wed Jul 15 00:19:20 CST 2020 on pts/1
[liwm@riyimei ~]$
[liwm@riyimei ~]$ su -
Password:
Last login: Wed Jul 15 00:17:09 CST 2020 on pts/1
Last failed login: Wed Jul 15 00:21:02 CST 2020 on pts/1
There were 3 failed login attempts since the last successful login.
[root@riyimei ~]#
不加入wheel组的普通用户无法切换到root权限
auth required pam_wheel.so use_uid
sed -i ‘/#%PAM/a\auth required pam_wheel.so use_uid’ /etc/pam.d/su