前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >RHEL7及CentOS7中让指定用户才能su到root-系统管理(3)

RHEL7及CentOS7中让指定用户才能su到root-系统管理(3)

作者头像
耕耘实录
发布2018-12-20 12:02:30
1K0
发布2018-12-20 12:02:30
举报
文章被收录于专栏:耕耘实录耕耘实录

在默认情况下,任何普通用户都能通过su命令切换到root用户。众所周知,root对于系统拥有至高无上的权限!因此,任何用户不在允许范围内切换到root都会威胁着整个系统的安全。增加指定用户才能su到root的系统管理设置相当于又给系统安全提升了一道安全屏障。 一、目标: 1. 只有指定用户才能su到root; 2. root在无需输入密码的情况下依然能够随时su到各普通用户; 3. 普通用户之间无法随意su,只能用已设置账户su到其他账户,其他账户不能su到已设置账户。 二、操作步骤 1.将指定能够su到root的用户附加至wheel组。默认情况下root是属于wheel组的。例如:将用户Geeklp附加至wheel组,命令如下:

[root@Geeklp-Administrator ~]# usermod -a Geeklp -G wheel
[root@Geeklp-Administrator ~]# id Geeklp
uid=1000(Geeklp) gid=1000(Geeklp) 组=1000(Geeklp),10(wheel),5001(sftp)

2.修改/etc/pam.d/su配置文件。将以下行的注释去掉。

auth            required        pam_wheel.so use_uid

三、验证

[root@Geeklp-Administrator ~]# su Geeklp #--root用户su到指定用户Geeklp,无需输入密码
[Geeklp@Geeklp-Administrator root]$ su test
密码:#--指定用户Geeklp用户su到test用户,需要输入test用户密码
[test@Geeklp-Administrator root]$ su Geeklp
密码:#--一般用户su到指定用户,权限拒绝
su: 拒绝权限
[test@Geeklp-Administrator root]$ su root
密码: #--一般用户su到root用户,权限拒绝
su: 拒绝权限

root用户su到普通用户后su不回来了,怎么办?exit呀!So easy!

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017年12月20日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档