1) 检测系统环境
[root@srv1 ~]# aide --check
AIDE, version 0.15.1
### All files match AIDE database. Looks okay!# 当前系统环境与数据库记录一致
2) 更改一个文件属性/权限做aide测试
[root@srv1 ~]# ll anaconda-ks.cfg
-rw-------. 1 root root 1838 Feb 22 17:40 anaconda-ks.cfg
[root@srv1 ~]# chmod 644 anaconda-ks.cfg
[root@srv1 ~]# ll anaconda-ks.cfg
-rw-r--r--. 1 root root 1838 Feb 22 17:40 anaconda-ks.cfg
[root@srv1 ~]# aide -C # -C就是--check参数
AIDE 0.15.1 found differences between database and filesystem!!
Start timestamp: 2020-02-28 01:14:24
Summary:
Total number of files: 57282
Added files: 0
Removed files: 0
Changed files: 1 # 检测到有1个修改的文件
---------------------------------------------------
Changed files:
---------------------------------------------------
changed: /root/anaconda-ks.cfg # 修改的文件名
---------------------------------------------------
Detailed information about changes:
---------------------------------------------------
File: /root/anaconda-ks.cfg
Perm : -rw------- , -rw-r--r-- # 修改的信息
ACL : old = A:
----
user::rw-
group::---
other::---
----
D: <NONE>
new = A:
----
user::rw-
group::r--
other::r--
----
D: <NONE>
3) 如果确认检测出来的差异是合法的,需要重新生成新的aide数据库
[root@srv1 ~]# aide --update
[4/501]
AIDE 0.15.1 found differences between database and filesystem!!
Start timestamp: 2020-02-28 01:20:56
Summary:
Total number of files: 57282
Added files: 0
Removed files: 0
Changed files: 1
---------------------------------------------------
Changed files:
---------------------------------------------------
changed: /root/anaconda-ks.cfg
---------------------------------------------------
Detailed information about changes:
---------------------------------------------------
File: /root/anaconda-ks.cfg
Perm : -rw------- , -rw-r--r--
ACL : old = A:
----
user::rw-
group::---
other::---
----
D:<NONE>
new = A:
----
user::rw-
group::r--
other::r--
----
D: <NONE>
[root@srv1 ~]# cp -p /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
4) 定期检测并发送检测通知
[root@srv1 ~]# vim /etc/cron.d/aide
00 00 * * * /usr/sbin/aide --update | mail -s 'Daily Check by AIDE' root
|