1. 设置密码复杂度
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| vi /etc/pam.d/system-auth
password requisite pam_pwquality.so dcredit=-1 lcredit=-1 ucredit=-1 ocredit=-1 minlen=8 try_first_pass local_users_only retry=10 authtok_type='设置账号(要求:大小写+特殊字符+数字>8位)'
dcredit=-1 lcredit=-1 ucredit=-1 ocredit=-1 minlen=8
retry=5 定义登录、或修改密码失败后,可以重复的次数 type= 选项,定义用户修改密码时的提示内容,一般不管 dcredit=-1 至少一个数字 lcredit=-1 至少一个小写 ucredit=-1 至少一个大写 ocredit=-1 至少一个特殊字符 minlen=8 密码最短长度为5位 remember=5 不能重复使用前5次使用过的密码
|
1 2 3 4
| [root@dahouzi-node005 ~]# vi /etc/pam.d/system-auth [root@dahouzi-node005 ~]# passwd dahouzi 更改用户 dahouzi 的密码 。 新的 '设置密码要求:大小写+特殊字符+数字' 密码:
|
2. 设置系统日志保存时间
vi /etc/logrotate.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
weekly
rotate 24
create
dateext
include /etc/logrotate.d
/var/log/wtmp { monthly create 0664 root utmp minsize 1M rotate 6 }
/var/log/btmp { missingok monthly create 0600 root utmp rotate 6 }
service rsyslog restart
|
3. MySQL审计
- 开启
set global general_log=on
- 检查
show variables like ‘%general_log%’
笔记隔离
1、打开防火墙
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| firewall-cmd --list-all firewall-cmd --reload systemctl restart firewalld.service systemctl stop firewalld.service systemctl start firewalld.service systemctl status firewalld.service
# 设置三台虚拟机互通(不做防火墙限制) firewall-cmd --permanent --add-source=10.128.136.138 firewall-cmd --permanent --add-source=10.128.136.139 firewall-cmd --permanent --add-source=10.128.136.140 firewall-cmd --permanent --add-source=10.128.136.140 firewall-cmd --permanent --add-source=113.98.244.181 firewall-cmd --permanent --remove-port=60022/tcp firewall-cmd --permanent --remove-port=22/tcp firewall-cmd --reload firewall-cmd --reload
|
2、检测到远端X服务正在运行中(CVE-1999-0526)
1 2 3 4 5 6
| 停止Xserver systemctl stop gdm systemctl disable gdm systemctl status gdm systemctl start gdm systemctl enable gdm
|
3、可通过HTTP获取远端WWW服务信息
关闭nginx 80/443端口
注释以下路径的80端口侦听
/data/middleware/nginx/config/conf.d/
4、修改ssh版本号(版本欺骗)
1 2 3 4
| cp /usr/bin/ssh /usr/bin/ssh.bak cp /usr/sbin/sshd /usr/sbin/sshd.bak sed -i 's/OpenSSH_7.4/OpenSSH_8.6/g' /usr/sbin/sshd sed -i 's/OpenSSH_7.4/OpenSSH_8.6/g' /usr/bin/ssh
|
5、SSH版本信息可被获取(修复)
修改源代码或者配置文件改变SSH服务的缺省banner。
1 2 3 4 5
| echo "Welcome to XX Airport" > /etc/ssh_banner_idszt vi /etc/ssh/sshd_config echo "Banner /etc/ssh_banner_idszt" >> /etc/ssh/sshd_config tail -n 10 /etc/ssh/sshd_config systemctl restart sshd
|
6、检测到远端RPCBIND/PORTMAP正在运行中(CVE-1999-0632)
1 2 3
| 关闭 rpcbind 服务 systemctl disable rpcbind systemctl stop rpcbind.socket
|
7、修复ICMP timestamp请求响应漏洞
- 在您的防火墙上过滤外来的ICMP timestamp(类型 13)报文以及外出的ICMP timestamp回复报文
1 2 3 4 5 6 7
| firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 0 -p ICMP --icmp-type timestamp-request -m comment --comment "deny ICMP timestamp" -j DROP firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 0 -p ICMP --icmp-type timestamp-reply -m comment --comment "deny ICMP timestamp" -j DROP # 禁止Traceroute探测 firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 0 -p ICMP --icmp-type 11 -m comment --comment "deny traceroute" -j DROP firewall-cmd --reload
firewall-cmd --direct --get-all-rules
|
8、修改ssh端口(慎重选择)
先操作一台机器,不同时操作。因为修改端口后,数据包不一定能通过防火墙。
配置文件调整/etc/ssh/sshd_config
1 2 3 4 5
| vi /etc/ssh/sshd_config
#port 22 #改为 port 60022
|
systemctl restart sshd
检查: netstat -ntlp
基线脚本执行
1、上传文件夹Linux_配置规范_已修改_S3A3G3到root目录
2、cd /root
3、执行chmod +x ffabcdef-2021-1115-1707-aaa510893517.sh
4、cd /tmp
5、导出xml文件
时间服务:10.128.143.33