rhel(centos)6/7 切换root用户无密码

rhel(centos)6/7 下,每当我们使用普通用户切换root用户时,都提示输入密码。但是在某些情况下(比如个人的电脑)就显得有些麻烦。

所以,无密码切换root就有必要了。

centos7/rhel7用户可按照对配置文件进行更改来实现:

配置文件名称:

/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-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.s


当然在对文件的更改完成之后,还需要将用户加入到wheel中

    usermod -G wheel username

只需要注意标红的四行的就可理解。从中,也看出来这是系统本身就配置好的,至需要我们稍加修改就能实现。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值