Linux 禁止普通用户su到root
Linux账户权限管理上为了防止普通用户通过su切换到root用户,需要修改/etc/pam.d/su和/etc/login.defs两个配置文件。
Step1:修改 /etc/pam.d/su文件
[root@ess ~]# vi /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
"/etc/pam.d/su" 14L, 540C
#%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
Step2:修改/etc/login.defs,末尾追加SU_WHEEL_ONLY yes
#
# If defined, this command is run when removing a user.
# It should remove any at/cron/print jobs etc. owned by
# the user to be removed (passed as the first argument).
#
#USERDEL_CMD /usr/sbin/userdel_local
#
# If useradd should create home directories for users by default
# On RH systems, we do. This option is overridden with the -m flag on
# useradd command line.
#
CREATE_HOME yes
# The permission mask is initialized to this value. If not specified,
# the permission mask will be initialized to 022.
UMASK 077
# This enables userdel to remove user groups if no members exist.
#
USERGROUPS_ENAB yes
# Use SHA512 to encrypt password.
ENCRYPT_METHOD SHA512
SU_WHEEL_ONLY yes
Step3:使用普通账户登录系统进行su测试
[tom@ess ~]$ su -
密码:
su: 拒绝权限
[tom@ess ~]$
说明:其他需要有权限root的用户需要添加至wheel组中,如下图:
[root@ess ~]# usermod -G wheel networking
[root@ess ~]# id networking
uid=1001(networking) gid=1001(networking) 组=1001(networking),10(wheel)
[root@ess ~]#
Linux 禁止普通用户su到root的更多相关文章
- Linux禁止普通用户su至root
linux系统为了限制权限,有时候需要禁止普通用户su到root用户 为禁止普通用户su至root,需要分别修改/etc/pam.d/su和/etc/login.defs两个配置文件. 二.详细配置 ...
- Linux安全加固(二)禁止普通用户su到root/设置SSH终端接入白名单/修改history条数
一.禁止普通用户su到root管理员.设置可以su到root的白名单 1.首先看一下正常情况 2.可以看到普通用户使用su root命令,输入密码即可登录到root用户 3.下面开始配置禁止所有普通用 ...
- centOS禁止普通用户su到root
1.关于su的相关权限涉及到两个文件,分别为/etc/pam.d/su和/etc/login.defs两个配置文件. 2.禁止普通用户su到root,配置如下: 去除/etc/pam.d/su文件中如 ...
- 普通用户su 到root,无需密码方式,及iptables封掉本机某个端口,core文件配置
一. 普通用户su到root无需密码: 随着服务器越来越多,普通用户转到root下,去查密码表是个很繁琐的事,发现有如下方式比较方便(需要root操作) vi /etc/pam.d/su 将 aut ...
- linux下添加用户并赋予root权限
1.添加用户,首先用adduser命令添加一个普通用户,命令如下: #adduser tommy //添加一个名为tommy的用户#passwd tommy //修改密码Changing pass ...
- linux下加入用户并赋予root权限
1.加入用户.首先用adduser命令加入一个普通用户,命令例如以下: #adduser tommy //加入一个名为tommy的用户 #passwd tommy //改动password Cha ...
- Linux禁止普通用户使用crontab命令
cron计划任务默认root用户与非root用户都可以执行,当然如果在安全方面想禁用这部分用户,则可以通过两个文件来解决: cron.allow cron.deny cron.allow:定义允许使用 ...
- Linux进入单用户模式(passwd root修改密码)
进入单用户模式——passwd root修改密码 1.在grub 页面输入a,进入修改内核模式 2.在内核的结尾“/”,输入空格,在输入single,回车 3.启动系统,进入单用户模式 4.Passw ...
- linux禁止普通用户登录
要想禁止普通用户登录 方法如下: 在 /etc下创建一个 nologin的文件 编辑这个文件,输入内容,当普通用户登录时就会提示这个文件的内容,并且禁止登陆. 执行步骤: touch /etc/nol ...
随机推荐
- ios-密码判断
我们经常在项目时有涉及到用户或是手机号登录,这时一般会配合密码才能登录成功. 下面发一些关于手机和密码形式的判断: - (void)registButtonClick:(id)sender { )// ...
- 解决ansible上传速度慢的问题
问题: 假如有A.B.C.D....等机器,机器A为Ansible服务器,机器B.C.D...等为Ansible管理的节点服务器,A机器与其他机器都不在同一个网络,也就是A机器必须添加VPN之后才能与 ...
- LOJ 2991 「THUSC 2016」补退选——trie+线段树合并或vector
题目:https://loj.ac/problem/2291 想了线段树合并的做法.就是用线段树维护 trie 的每个点在各种时间的操作. 然后线段树合并一番,线段树维护前缀最大值,就是维护最大子段和 ...
- JavaBasic_正则表达式
就是符合一定规则的字符串 规则字符在java.util.regex.Pattern类中 字符转义\. 匹配.字符\* 匹配*字符\\ 匹配\字符\n 新行(换行)符 ('\u000A') \r 回车符 ...
- 搜狗浏览器总是打开123.sogou.com-记搜狗浏览器遭遇劫持一例
昨日,因从网上下载了office2010破解工具,压缩包中有个文件为名为[office 2010激活工具\为保证永久激活,要先点击这个配置,再点击KMSELDIYI激活.exe],单击之后没有反应.后 ...
- sitemesh使用
参考文章: https://my.oschina.net/heroShane/blog/199177 http://blog.csdn.net/u013019926/article/details/1 ...
- 20165312 2017-2018-2《JAVA程序设计》第7周学习总结
20165312 2017-2018-2<JAVA程序设计>第7周学习总结 一.对上周测试的查漏补缺 总的来说,我觉得上周两个测试都挺难的,做测试也花费了很长的时间,我认为是因为书上的知识 ...
- 保存数据到Excel中
调用的方法传值 Export(dt, "Cal_Report_" + DateTime.Now.ToString("yyyyMMddhhmmss") + &qu ...
- Android Studio计时跳转或点击跳转至主页面
这个总体来说是比较简单的,计时跳转一般调用Android Studio中的Handler方法. 一.发生点击事件跳转页面 mBtnTextView = (Button) findViewById(R. ...
- 7-安装Spark
1.Apache Hadoop2.7中的YARN与JAVA8有冲突,如果想要使用spark on yarn,首先需要在yarn-site.xml中配置如下项: <property> < ...