Debian 上 Python 安全策略配置
一 系统基线加固
二 Python 运行环境与依赖管理
三 代码与运行时的安全控制
四 可选强化与合规
五 快速检查清单
| 检查项 | 期望状态 | 验证命令或路径 |
|---|---|---|
| 系统与安全更新 | 已启用自动安全更新 | sudo unattended-upgrades --dry-run |
| 防火墙 | 仅放行 22/80/443 | sudo ufw status 或 sudo iptables -S |
| SSH | root 远程登录禁用 | grep -E ‘^PermitRootLogin’ /etc/ssh/sshd_config |
| fail2ban | 已运行并启用 SSH 防护 | sudo systemctl status fail2ban;sudo fail2ban-client status sshd |
| Python 虚拟环境 | 项目均使用 venv | ls */bin/activate 或 which python |
| pip 配置 | 使用可信源与校验 | cat /etc/python3/pip.conf |
| 日志监控 | 日志收集与告警已配置 | sudo systemctl status logwatch;查看 /var/log/ 与监控平台告警 |