问题现象

使用su命令时输入密码后提示权限限制,确认密码是正确的

su root
Password:
su: permission denied

解决办法

改变用户分组,将用户添加进wheel分组

#语法
# usermod [-G] [GroupName] [UserName]
usermod -G wheel username 

修改/etc/pam.d/su

vim /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

修改如下图选中行,注释掉
在这里插入图片描述

原因分析

PAM(Pluggable Authentication Modules)负责系统中很多应用程序的登录认证,安全设置问题

附录

查看用户当前分组

#语法
# id username
id user1
#执行结果如下
uid=1008(user1) gid=1008(user1) groups=1008(user1),1012(mygroup)
Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐