Centos 普通用户su到root用户提示错误

一、CentOS7

普通用户执行su时,报如下错误:

[test@ecs-1453 ~]$ su -
Password: 
su: Authentication failure

解决方法:

如果root能够正常登陆,就先使用root用户登录系统,再执行操作

1、登陆root账户;
2、执行sudo -i

[root@ecs-1453 ~]# sudo -i

3、执行chmod +s /bin/su

[root@ecs-1453 ~]# chmod +s /bin/su

4、验证

[test@ecs-1453 ~]$ su - root
Password: 
su: Authentication failure
[test@ecs-1453 ~]$ su - root
Password: 
Last login: Tue Feb 27 18:44:34 CST 2018 on pts/0
Last failed login: Tue Feb 27 18:45:42 CST 2018 on pts/1
There was 1 failed login attempt since the last successful login.

二、centos6

普通用户执行su时,报错如下:

[test@ecs-19cb ~]$ su - root
Password: 
su: incorrect password

解决方法:

如果root能够正常登陆,就先使用root用户登录系统,再执行操作

1、登陆root账户;
2、查看/etc/pam.d/su配置文件,#auth required pam_wheel.so use_uid 这句是否被启用,如果启用了,那么加入了wheel组的用户(usermod -g  wheel 用户id)才能su,否则就会提示密码错误。

[root@ecs-19cb ~]# 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            include         system-auth
account         sufficient      pam_succeed_if.so uid = 0 use_uid quiet
account         include         system-auth
password        include         system-auth
session         include         system-auth
session         optional        pam_xauth.so#auth            required       pam_wheel.so use_uid
auth            include         system-auth
account         sufficient      pam_succeed_if.so uid = 0 use_uid quiet
account         include         system-auth
password        include         system-auth
session         include         system-auth
session         optional        pam_xauth.so

3、查看文件权限,正确如下

[root@ecs-19cb ~]# ll -a /bin/su 
-rwsr-xr-x. 1 root root 34904 May 11  2016 /bin/su
[root@ecs-19cb ~]# ll -a /usr/bin/passwd 
-rwsr-xr-x. 1 root root 30768 Nov 24  2015 /usr/bin/passwd

4、验证

[test@ecs-19cb ~]$ su - root
Password: 
su: incorrect password
[test@ecs-19cb ~]$ su - root
Password: 
[root@ecs-19cb ~]#

  • 5
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

友人a笔记

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值