linux su 不能输密码错误,su - root正确输入密码但是登录不了系统,报错su: Permission denied...

su - root输入了正确的密码但是一直报错,密码肯定是输入对的。这主要是因为权限的问题导致的。

Linux里面有一个文件,/etc/pam.d/su文件。

[[email protected] ~]$ cat /etc/pam.d/su

#%PAM-1.0

authsufficientpam_rootok.so

# Uncomment the following line to implicitly trust users in the "wheel" group.

#authsufficientpam_wheel.so trust use_uid

# Uncomment the following line to require a user to be in the "wheel" group.

#authrequiredpam_wheel.so use_uid

authsubstacksystem-auth

authincludepostlogin

accountsufficientpam_succeed_if.so uid = 0 use_uid quiet

accountincludesystem-auth

passwordincludesystem-auth

sessionincludesystem-auth

sessionincludepostlogin

sessionoptionalpam_xauth.so

主要是看第5、6这两行。如果把第6行注释打开了,那么只有那些加入了wheel组的普通用户才可以使用su - root来切换到root用户,比如如下所示:

现在有两个用户,一个是chaofeng,一个是chaofan。这两个用户中,chaofeng是加入到了wheel组里面的,如下所示:

[[email protected] ~]# id chaofeng

uid=1000(chaofeng) gid=1000(chaofeng) groups=1000(chaofeng),10(wheel)

[[email protected] ~]# id chaofan

uid=1001(chaofan) gid=1001(chaofan) groups=1001(chaofan)

然后现在我处于chaofeng这个用户登录的终端里面,执行su - root

[[email protected] ~]# su - chaofeng

Last login: Thu Jul 2 11:40:15 CST 2020 on pts/1

[[email protected] ~]$ su - root

Password:

Last login: Thu Jul 2 11:40:21 CST 2020 on pts/1

Last failed login: Thu Jul 2 11:42:33 CST 2020 on pts/1

There were 3 failed login attempts since the last successful login.

[[email protected] ~]# # 看的出来我现在登录成功了

接着现在我处于chaofan这个用户登录的终端里面,再次执行su - root尝试

[[email protected] ~]# su - chaofan

Last login: Thu Jul 2 11:42:19 CST 2020 on pts/1

[[email protected] ~]$ su - root

Password:

su: Permission denied

[[email protected] ~]$

我可以保证输入的root用户的密码是没有错误的,但是一直报错“su: Permission denied”。

所以从这里可以看出来/etc/pam.d/su我们去掉的这一行的作用所在了。

原文:https://www.cnblogs.com/FengGeBlog/p/13223920.html

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值