当前位置:网站首页>【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
边栏推荐
- 公网IP地址和SSL证书可以提升SEO吗?
- 开源项目,私活利器,快速开发
- Apache Hadoop的重要组成
- SQL server attached database access denial resolution summary
- Configure the NZ date picker time selection component of ng zerro
- 日常页码样式问题
- The movie theater booking system based on micro Service Framework
- More than 60 technical executives gathered in Songshan Lake, and the first phase of Huawei cloud core partner developer training camp was successfully concluded
- On the practical application of C 9's new features
- 2018中国云厂商TOP5:阿里云、腾讯云、AWS、电信、联通 ...
猜你喜欢

C + + game development

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

IP address SSL certificate

AQS source code in-depth analysis of conditional queue

How to upload your avatar with code and add your own copyright information?

C/C++编程日记:逻辑井字棋(圈叉)游戏开发

当我们开发一个接口时需要注意些什么

Operation! Nested JSON second change dataframe!

Analysis steps of commodity background management

How much is the cost of CRM system?
随机推荐
CUDA_存储器模型
CUDA常用概念及注意点
How to upload your avatar with code and add your own copyright information?
sql 筛选查询重复列
Operation and design of rights management in ERP
Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom
害怕重构?都怪我太晚和你介绍该如何重构,现在我来了
那么当下的行情投资者该怎么办呢? 现在新的投资风口来了!
做个别人家的网页
Nodejs: handwritten koa Middleware
On the practical application of C 9's new features
IP地址SSL证书
函数计算进阶-IP查询工具开发
嘉宾专访|2020 PostgreSQL亚洲大会阿里云数据库专场:王健
So what should investors do with the current market? Now a new investment outlet is coming!
刚毕业都会迷茫,我经过7年总结,送给程序员的你们7点建议
Operation! Nested JSON second change dataframe!
Hand in hand to teach you to use container service tke cluster audit troubleshooting
nodejs篇-手写koa中间件
如何用代码上传头像,并添加自己的版权信息?