您的当前位置:首页 --> CentOS入门
centos7切换root用户设置无密码
浏览次数:2943 关键词 ( 密码  用户  root  )

centos7 下,每当我们使用普通用户切换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

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

下载次数:45
下载地址:点击下载
本资源为程序自动采集,如有侵权请联系我们移除 admin#80vps.com 来信请将#替换为@
下一条 centos系统中网络配置相关
上一条 Centos最小化安装后调整终端分辨率

拥有超过10年的业务管理经验。我们是IDC服务和解决方案方面的专家

有任何疑问请不要犹豫,立即点击联系我们