1、找到su文件进行编辑,此处需要切换至root操作;
vim /etc/pam.d/su
2、取消su文件的这行注释;
# Uncomment the following line to implicitly trust users in the "wheel" group.
auth sufficient pam_wheel.so trust use_uid
3、将目标账户加入wheel组;
usermod -G wheel {xxx}
设置时去掉{}即可成功。
配置参考:CentOS免密码切换至root