root用户和普通用户免密切换配置

1、免密切换root用户的方法

su root
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.
#au
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

# 将普通用户添加到wheel组中
usermod -G wheel info12

2、使用ssh或telnet登陆后如何自动切换root

su info12
cd
vim .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
sudo su - root #加入这么一个授权的命令
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
su root 
vim /etc/sudoers
root    ALL=(ALL)      ALL
chenfei ALL=(ALL)      NOPASSWD: ALL #在root后面添加普通用户
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值