“CentOS exploit(漏洞利用)”加固的核心目标是:及时修补已知漏洞、减少攻击面、加强系统防护。下面从系统补丁、服务配置、权限控制、网络安全、入侵检测几个方面给你一份实用的 CentOS 加固清单。
yum update -y
或(CentOS 8+ / Stream):
dnf update -y
查看未修复漏洞:
yum updateinfo list security
yum install yum-cron -y
systemctl enable yum-cron
systemctl start yum-cron
配置:
vi /etc/yum/yum-cron.conf
设置:
update_cmd = security
apply_updates = yes
vi /etc/ssh/sshd_config
建议:
PermitRootLogin no
PasswordAuthentication no
Port 22222
MaxAuthTries 3
LoginGraceTime 20
ClientAliveInterval 300
重启:
systemctl restart sshd
ssh-keygen
ssh-copy-id user@host
systemctl list-unit-files --type=service | grep enabled
关闭示例:
systemctl disable telnet
systemctl stop telnet
systemctl enable firewalld
systemctl start firewalld
只开放必要端口:
firewall-cmd --permanent --add-port=22222/tcp
firewall-cmd --reload
passwd -l username
usermod -aG wheel username
chmod 700 /etc/shadow
chmod 644 /etc/passwd
getenforce
setenforce 1
永久:
vi /etc/selinux/config
SELINUX=enforcing
sysctl -w net.ipv4.conf.all.accept_redirects=0
sysctl -w net.ipv4.tcp_syncookies=1
yum install fail2ban -y
systemctl enable fail2ban
防止暴力破解。
lynisOpenSCAPclamav(杀毒)如果你是指具体漏洞(如:
请:
我可以给你精准修复命令。
CentOS 防 exploit = 补丁 + 最小权限 + 防火墙 + SELinux + 监控
如果你愿意,可以告诉我:
我可以帮你做一份定制加固方案。