以下是为您整合的修复清单
| 类别 | 风险项简描述 | 关键操作/命令 | 注意事项 |
|---|---|---|---|
| 内核参数 (sysctl) | 禁用IPv4/IPv6重定向、转发、源路由等 | 1. 编辑 /etc/sysctl.conf,在末尾一次性添加以下所有参数: net.ipv4.conf.all.send_redirects = 0 net.ipv4.conf.default.send_redirects = 0 net.ipv4.conf.all.accept_redirects = 0 net.ipv4.conf.default.accept_redirects = 0 net.ipv4.conf.all.secure_redirects = 0 net.ipv4.conf.default.secure_redirects = 0 net.ipv4.conf.all.accept_source_route = 0 net.ipv4.conf.default.accept_source_route = 0 net.ipv4.ip_forward = 0 net.ipv4.icmp_echo_ignore_broadcasts = 1 net.ipv4.icmp_ignore_bogus_error_responses = 1 net.ipv4.conf.all.log_martians = 1 net.ipv4.conf.default.log_martians = 1 net.ipv6.conf.all.accept_redirects = 0 net.ipv6.conf.default.accept_redirects = 0 net.ipv6.conf.all.accept_ra = 0 net.ipv6.conf.default.accept_ra = 0 net.ipv6.conf.all.accept_source_route = 0 net.ipv6.conf.default.accept_source_route = 0 net.ipv6.conf.all.forwarding = 0 2. 使配置立即生效: sysctl -p |
【关键】 如果您的服务器是 Docker宿主机 或需要做 路由器/网关 ,请忽略 ip_forward 和 forwarding 的设置。 |
| 内核模块禁用 | 禁用jffs2, tipc, sctp, udf, dccp, rds等不必要模块 | 1. 创建或编辑 /etc/modprobe.d/CIS.conf 新建**CIS.conf文件** 添加: install jffs2 /bin/true install tipc /bin/true install sctp /bin/true install udf /bin/true install dccp /bin/true install rds /bin/true 2. 可选:禁用IPv6(如果完全不用): options ipv6 disable = 1 |
禁用内核模块可以减少攻击面。执行后需重启系统才能完全生效。 |
| SSH服务加固 | 设置Banner、禁用PermitUserEnvironment | 1. 编辑 /etc/ssh/sshd_config: PermitUserEnvironment no 去掉前面的#号 2. 重启SSH服务: systemctl restart sshd |
务必在重启sshd前,保持另一个SSH会话窗口开启,防止配置错误导致无法登录。 |
| 系统与登录安全 | 配置登录标语、/tmp挂载选项、Postfix仅本地 | 1.检查是否清理本地登录标语 直接复制下面的命令 终端执行 # 2. 替换issue文件内容(覆盖敏感变量) echo "Authorized uses only. All activity may be monitored and reported." > /etc/issue echo "Authorized uses only. All activity may be monitored and reported." > /etc/issue.net 2. /tmp挂载 :根据您的系统(CentOS/Debian)按方案编辑fstab或systemd mount文件,并执行 mount -o remount,nosuid /tmp 3. Postfix :postconf -e 'inet_interfaces = 127.0.0.1' 然后 systemctl restart postfix |
如果非邮件服务器,限制Postfix可降低风险。 |
| 时间同步 | 规范NTP或Chrony配置 | 根据您使用的服务二选一: NTP :编辑 /etc/ntp.conf 添加 restrict 行,然后 systemctl enable --now ntpd Chrony :确保配置正确并在 OPTIONS 中添加 -u chrony,然后 systemctl enable --now chronyd |
确保时间同步服务正常运行对日志分析至关重要。 |
| 【检测到已安装telnet客户端:/usr/bin/telnet,/bin/telnet 解决方案 1、卸载(CentOS/RHEL):yum remove telnet | |||
| 系统更新 | 系统安全更新(最核心步骤) 必须操作:登录宝塔面板,进入 【安全】->【防篡改】 ,将其临时关闭。这是后续更新成功的前提。 执行安全更新 1. 运行: sudo dnf upgrade-minimal --security -y 2.若遇到包依赖冲突(最常见),使用: sudo dnf upgrade-minimal --security -y --allowerasing 3.验证更新:运行 查看列表是否已清空或大幅减少 sudo dnf updateinfo list security 如果提示需要重启,请安排时间重启服务器以使更新生效。 4.检查重启需求:运行 sudo dnf needs-restarting -r 若提示需重启(通常都会),则安排重启。 操作建议: 通过阿里云控制台或宝塔面板重启服务器,这样更安全可靠。 5. 重启后检查是否还有更新: sudo dnf updateinfo list security 理想结果应为空。 操作顺序: 请严格遵循 "关闭防篡改 → 执行更新 → 重启 → 重开防篡改" 的顺序 |