当前位置:网站首页>【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
边栏推荐
- SSL证书和公网IP地址如何影响SEO
- Another comparison operator related interview question let me understand that the foundation is very important
- SQL intercepts the data before and after the '.'
- sql 筛选查询重复列
- 如何实现LRU算法
- From master of Engineering Physics of Tsinghua University to open source entrepreneur of cloud computing
- input 与 button 的问题 (空隙/不等高/对不齐)及 解决办法
- Performance evaluation report of YoMo codec - Y3
- Configure the NZ date picker time selection component of ng zerro
- JT-day10
猜你喜欢

Analysis steps of commodity background management

Common settings of PLSQL developer

The problem of looting by leetcode

Validation failed for one or more entities. See ‘EntityValidationErrors’解决方法

ES6, ES7, es8 Learning Guide

From master of Engineering Physics of Tsinghua University to open source entrepreneur of cloud computing

The movie theater booking system based on micro Service Framework

Optimization of commodity backstage system
![Python中[:]与[::]的用法](/img/3b/00bc81122d330c9d59909994e61027.jpg)
Python中[:]与[::]的用法

Just graduated will be confused, I after 7 years of summary, give programmers your 7 suggestions
随机推荐
开源项目,私活利器,快速开发
Important components of Apache Hadoop
刚毕业都会迷茫,我经过7年总结,送给程序员的你们7点建议
LinkedList源码简析
Expect ':' at 0, actual = (JSON conversion exception resolution)
手把手教你使用容器服务 TKE 集群审计排查问题
From master of Engineering Physics of Tsinghua University to open source entrepreneur of cloud computing
CUDA_共享内存、访存机制、访问优化
PL/SQL Developer临时用户和新手的功能指南
Operation and design of rights management in ERP
毕业即失业?大学生如何分配学习时间比例,拥有完整计算机知识体系?
Make a home page
jt-京淘项目
So what should investors do with the current market? Now a new investment outlet is coming!
Kubernetes-18: installation and use of dashboard
lvgl 库 V7版本相关应用
SQL intercepts the data before and after the '.'
SQL filter query duplicate columns
[QT] subclass QObject + movetothread to realize multithreading
Dongge ate grapes when he ate an algorithm problem!