当前位置:网站首页>【CentOS7操作系统安全加固系列】第(2)篇
【CentOS7操作系统安全加固系列】第(2)篇
2020-11-09 22:42:00 【yuanfan2012】
点击上方"walkingcloud"关注,并选择"星标"公众号


1、口令重复次数限制
规则描述:重新启用某个旧密码,要确保此密码在继上次使用后已被修改过几次。此策略是管理员能够通过确保旧密码不被连续重新使用来增强安全性
审计描述:检查文件/etc/pam.d/system-auth和文件/etc/pam.d/password-auth是否存在如下配置:password sufficient pam_unix.so remember=5 或password required pam_pwhistory.so remember=5 其中remember选项大于等于5
修改建议:编辑配置文件/etc/pam.d/system-auth和文件/etc/pam.d/password-auth修改或添加配置:password sufficient pam_unix.so remember=5 或password required pam_pwhistory.so remember=5 备注:使用remember=5配置覆盖原有模块配置
实际解决方法:编辑配置文件/etc/pam.d/system-auth和文件/etc/pam.d/password-auth修改或添加如下配置
password required pam_pwhistory.so use_authtok remember=5


2、文件与目录缺省权限控制
规则描述:该设置确定新创建的目录和文件的默认权限
审计描述:检查/etc/profile, /etc/profile.d/.sh, /etc/bashrc的umask配置为027(或者0027)
修改建议:设置/etc/profile /etc/profile.d/.sh、/etc/bashrc文件中的umask配置为027(或者0027)
umask值含义:当用户新创建文件或目录时,该文件或目录具有一个缺省权限。该缺省权限由umask值来指定。umask值代表的是权限的“补码”,即用缺省最大权限值减去umask值得到实际权限值。
文件的缺省最大权限为可读可写,目录的缺省最大权限为可读可写可执行。
即一个文件的实际缺省权限为666减去umask值。目录的实际缺省权限为777减去umask值
解决方法:
sed -i 's/umask 022/umask 027/g' /etc/profile
sed -i 's/umask 022/umask 027/g' /etc/bashrc
修改前

修改后

3、配置用户最小授权
规则描述:检查文件/etc/passwd、/etc/shadow、/etc/group、/etc/services、/etc/xinetd.conf和目录/etc/security的权限
审计描述:检查文件/etc/passwd、/etc/group、/etc/services的权限是否小于或等于644,检查文件/etc/shadow的权限是否小于或等于400,检查/etc/xinetd.conf文件、/etc/security目录权限是否小于等于600,检查以上文件及目录的属主和属组是否均为root:root
修改建议:设置文件/etc/passwd、/etc/group、/etc/services的权限为0644,设置文件/etc/shadow的权限为0400,设置文件/etc/xinetd.conf、目录/etc/security的权限为0600,
例如执行:chmod 600 /etc/passwd。设置以上文件及目录的属主和属组为root:root,例如执行:chown root:root /etc/passwd
检测用例信息:{ "checkDescription": "在目录/etc/security存在时,检查文件的权限,不存在则pass: stat --format="%U:%G %a" /etc/security 2>/dev/null", "current_value": "/etc/security root:root 0755", "suggest_value": "文件不存在或者/etc/security root:root 600(或者更严格)" }
解决过程
stat --format="%U:%G %a" /etc/passwd
stat --format="%U:%G %a" /etc/shadow
ll /etc/shadow
stat --format="%U:%G %a" /etc/group
stat --format="%U:%G %a" /etc/services
stat --format="%U:%G %a" /etc/security
chmod 600 /etc/security
stat --format="%U:%G %a" /etc/security

4、修改SSH的Banner警告信息
规则描述:检查ssh服务状态,若不开启则pass,若开启则检查是否设置ssh登录告警信息,设置则pass
审计描述:检查ssh服务状态,若不开启则pass,若开启则检查/etc/ssh/sshd_config文件,是否配置Banner,获取其路径文件,检查该文件是否不为空,不为空则pass
修改建议:如果ssh服务不需要,需要关闭该服务。如果需要ssh服务,则需要配置/etc/ssh/sshd_config文件中Banner
[root@VM_Server ~]# grep "^\s*Banner\s*" /etc/ssh/sshd_config 2>/dev/null | awk '{print $2}'
[root@VM_Server ~]# grep "Banner*" /etc/ssh/sshd_config 2>/dev/null | awk '{print $2}'
none
[root@VM_Server ~]# grep "Banner*" /etc/ssh/sshd_config 2>/dev/null
#Banner none
[root@VM_Server ~]# sed -i "s/#Banner none/Banner \/etc\/issue.net/g" /etc/ssh/sshd_config
[root@VM_Server ~]# echo "Authorized users only. All activity may be monitored and reported.">/etc/issue.net
[root@VM_Server ~]# service sshd restart


5、设置关键文件的属性
规则描述:检查/var/log/messages文件是否存在a属性
审计描述:检查/var/log/messages文件是否存在a属性:lsattr /var/log/messages | cut -b 6
修改建议:使用命令更改该日志文件属性:chattr +a /var/log/messages
lsattr /var/log/messages
lsattr /var/log/messages | cut -b 6
chattr +a /var/log/messages
lsattr /var/log/messages | cut -b 6

本文分享自微信公众号 - WalkingCloud(WalkingCloud2018)。
如有侵权,请联系 [email protected] 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。
版权声明
本文为[yuanfan2012]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4113630/blog/4709514
边栏推荐
- LinkedList源码简析
- ERP的权限管理的操作与设计--开源软件诞生24
- How to make a set of K reverse linked lists
- SQL case conversion, remove the space before and after
- Old system refactoring skills, easy to handle legacy code
- mongodb内核源码实现、性能调优、最佳运维实践系列-command命令处理模块源码实现一
- [graffiti Internet of things footprint] graffiti cloud platform interface description
- LeetCode 50 Pow(x,n)
- 白山云科技入选2020中国互联网企业百强
- 毕业即失业?大学生如何分配学习时间比例,拥有完整计算机知识体系?
猜你喜欢
随机推荐
剑指offer之打印超过数组一半的数字
CUDA_全局内存及访问优化
东哥吃葡萄时竟然吃出一道算法题!
LeetCode 50 Pow(x,n)
The basic principle of MRAM
PHP - curl copy paste access SMS verification code example
Error running app:Default Activity not found 解决方法
How to carry out modular power operation efficiently
正式班D25
mongodb内核源码实现、性能调优、最佳运维实践系列-command命令处理模块源码实现一
input 与 button 的问题 (空隙/不等高/对不齐)及 解决办法
win7+vs2015+cuda10.2配置TensorRT7.0
Python提示AttributeError 或者DeprecationWarning: This module was deprecated解决方法
Traditional purchasing mode has changed! How to innovate automobile purchasing function?
Prometheus安装配置
害怕重构?都怪我太晚和你介绍该如何重构,现在我来了
代码中的软件工程--对menu项目的源码分析
Configure the NZ date picker time selection component of ng zerro
Postman (1) -- function introduction
爱康国宾怒斥国信证券报告失实,已发律师函






