避免 Linux 被 exploit(漏洞利用/攻击)是一个系统性的安全工程,可以从以下几个层面来做。下面按“重要性 + 可操作性”整理,适合服务器和日常使用。
绝大多数 exploit 都针对已知漏洞,补丁已存在但没打。
# Debian / Ubuntu
apt update && apt upgrade -y
# RHEL / CentOS / Rocky
dnf update -y
# 或
yum update -y
# Ubuntu
apt install unattended-upgrades
dpkg-reconfigure unattended-upgrades
“能不装的就不装”
apt remove --purge telnet rsh rlogin
# /etc/ssh/sshd_config
PermitRootLogin no
PasswordAuthentication no
sudo 而不是长期 root# 查看监听端口
ss -tulnp
# UFW 示例
ufw default deny incoming
ufw allow 22
ufw allow 80
ufw enable
apt install fail2ban
# 查看
getenforce
aa-status
sysctl kernel.randomize_va_space=2
setuid 程序capabilities 替代 rootsystem() / eval()journalctl -xe
/var/log/auth.log
auditd
apt install aide
aideinit
| 风险点 | 建议 |
|---|---|
| 老旧内核 | 常更新 |
| 暴露 Redis / MongoDB | 绑定 localhost |
| 弱 SSH 密码 | 密钥登录 |
| 提权漏洞(SUID) | 定期扫描 |
| 容器逃逸 | 不跑特权容器 |
避免 Linux exploit = 少装 + 常更新 + 最小权限 + 网络隔离 + 监控
如果你愿意,我可以:
你是用在哪类环境?