当前位置:网站首页>【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
边栏推荐
- 刚毕业都会迷茫,我经过7年总结,送给程序员的你们7点建议
- LinkedList源码简析
- Technical point 5: XML language
- How to carry out modular power operation efficiently
- 2018中国云厂商TOP5:阿里云、腾讯云、AWS、电信、联通 ...
- 如何实现LRU算法
- Performance evaluation report of YoMo codec - Y3
- [best practice] learn how eolinker helps Telecommuting
- Gets the property value of a column in the list collection object
- 11.9
猜你喜欢
Technical point 5: XML language
如何用代码上传头像,并添加自己的版权信息?
Modify the files in the jar package
Important components of Apache Hadoop
11.9
CUDA_共享内存、访存机制、访问优化
Application of V7 version of lvgl Library
So what should investors do with the current market? Now a new investment outlet is coming!
[best practice] learn how eolinker helps Telecommuting
如何高效进行模幂运算
随机推荐
Optimization of commodity backstage system
PL/SQL Developer临时用户和新手的功能指南
函数计算进阶-IP查询工具开发
lvgl 库 V7版本相关应用
当我们开发一个接口时需要注意些什么
面试官:缓存穿透、缓存雪崩和缓存击穿是什么?
团灭 LeetCode 打家劫舍 问题
Markdown plug-in of vscode
正式班D25
Hand in hand to teach you to use container service tke cluster audit troubleshooting
剑指offer之打印超过数组一半的数字
ERP的权限管理的操作与设计--开源软件诞生24
Configure the NZ date picker time selection component of ng zerro
Gets the property value of a column in the list collection object
PHP - curl copy paste access SMS verification code example
Make a home page
mongodb内核源码实现、性能调优、最佳运维实践系列-command命令处理模块源码实现一
恒讯科技浅谈:出现服务器宕机的处理方式
crm系统的成本一般是多少?
CUDA常用概念及注意点