防御 Debian 系统上的 exploit(漏洞利用)风险,核心思路是:减少攻击面 + 及时修补 + 最小权限 + 监控响应。下面按「基础 → 进阶 → 实战清单」给你一份可落地指南。
Debian 绝大多数 exploit 都依赖未修复漏洞。
sudo apt update
sudo apt upgrade -y
sudo apt dist-upgrade -y
定期自动更新(推荐):
sudo apt install unattended-upgrades
sudo dpkg-reconfigure --priority=low unattended-upgrades
查看安全更新:
apt list --upgradable | grep security
越少服务 = 越少 exploit 目标。
sudo apt remove --purge telnet rsh-client
systemctl disable bluetooth
systemctl stop bluetooth
示例(UFW):
sudo apt install ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw enable
编辑 /etc/ssh/sshd_config:
PermitRootLogin no
PasswordAuthentication no
Port 2222
MaxAuthTries 3
然后:
systemctl restart ssh
✅ 使用 SSH 密钥 + Fail2ban
sudo apt install fail2ban
Debian 默认支持:
sudo apt install apparmor apparmor-profiles
aa-status
检查:
cat /proc/sys/kernel/randomize_va_space # 应为 2
确保启用:
Debian 默认已开启,不要手动关闭。
可选:
linux-image-hardenedmount | grep ' / ' # 确保无 exec, suid 异常
关键目录建议:
/tmp → noexec, nosuid
/etc/fstab
tmpfs /tmp tmpfs defaults,noexec,nosuid,nodev 0 0
sudo apt install rkhunter chkrootkit aide
rkhunter:rootkit 检测aide:文件完整性监控查看异常:
journalctl -p 3 -xb
关注:
debsecansudo apt install debsecan
debsecan
✅ 用 Stable 版本
✅ 自动安全更新
✅ 非 root + 密钥 SSH
✅ 防火墙只开必要端口
✅ AppArmor 开启
✅ 定期 debsecan + 日志审计
如果你愿意,我可以:
你当前用的是 Debian 几?服务器还是桌面?