systemctl enable auditd
systemctl start auditd
# 监控文件访问
auditctl -w /etc/passwd -p wa -k passwd_changes
# 监控系统调用
auditctl -a always,exit -F arch=b64 -S execve -k command_exec
# 监控特定用户
auditctl -a always,exit -F uid=1000 -k user_activity
# 查看当前规则
auditctl -l
# 持久化规则 /etc/audit/rules.d/audit.rules
-w /etc/sudoers -p wa -k sudoers_changes
-w /var/log/ -p wa -k log_changes
-a always,exit -F arch=b64 -S sethostname -k hostname_change
ausearch -k passwd_changes # 按 key 查询
ausearch -ts today # 按时间
ausearch -ua root # 按用户
aureport -l # 登录报告
aureport -f # 文件访问报告
aide --init # 初始化数据库
aide --check # 检查变更
aide --update # 更新基准
# 关键目录监控
# /etc/aide/aide.conf
/etc p+i+n+u+g+s+m+c+sha512
/bin p+i+n+u+g+s+m+c+sha512
/sbin p+i+n+u+g+s+m+c+sha512
CIS (Center for Internet Security) 提供 Linux 安全基线检查清单:
# Lynis 合规扫描
lynis audit system
lynis show recommendations
发现漏洞 (CVE) → 评估影响 → 测试修复 → 灰度部署 → 全量上线
↓
AIDE 验证文件完整性 → auditd 追踪变更