AIDE (Advanced Intrusion Detection Environment, pronounced “aid”) answers one question: has anything on this system changed that shouldn’t have? It records a baseline of your files, with checksums, permissions, owners, sizes, timestamps, ACLs and extended attributes, in a database. Every day it compares the live system against that baseline and reports every difference.
That makes it the classic tool for detecting a compromise after the fact: a replaced binary in /usr/bin, a new SUID file, a modified sshd_config, an extra key in authorized_keys. It’s also a common requirement in compliance frameworks such as PCI DSS, ISO 27001 and the CIS benchmarks.
This guide sets up AIDE on Debian 13 so that it:
- Checks daily through Debian’s systemd timer, running as an unprivileged user
- Actually delivers its report by mail (which, on Debian 13, doesn’t happen by default)
- Never accepts changes on its own: you review, then you update the baseline
- Ignores known noise with targeted local exclusions instead of blanket ones
- Keeps the baseline safe from an attacker with an off-host fingerprint
- Is tested with a deliberate change that has to show up in the report
Tested on: Debian 13 “trixie” with the Debian packages
aideandaide-common(AIDE 0.19.x). All commands run as root (or withsudo).
Table of contents
- Placeholders
- How AIDE works on Debian 13
- Install the packages
- Reporting settings
- Local rules and exclusions
- Build the baseline
- Protect the baseline
- The daily check
- Reviewing and accepting changes
- Testing
- Troubleshooting
- Checklist
1. Placeholders
| Placeholder | Meaning |
|---|---|
security@example.org | Where AIDE reports go |
backup.example.org | A separate host (or offline storage) that keeps the baseline fingerprint |
/var/www/example.org/public | Example of an application directory with legitimate churn |
2. How AIDE works on Debian 13
| Piece | Where | What it does |
|---|---|---|
aide | /usr/bin/aide | The checker itself |
| Main config | /etc/aide/aide.conf | Debian’s config. It pulls in every rule file from /etc/aide/aide.conf.d/. |
| Rule snippets | /etc/aide/aide.conf.d/ | One file per area (70_aide_etc, …), plus your local rules |
| Wrapper settings | /etc/default/aide | Mail recipient, report filtering, what to do with the new database |
| Baseline | /var/lib/aide/aide.db | The trusted state |
| New state | /var/lib/aide/aide.db.new | Written by every check run, but never trusted automatically |
| Daily run | dailyaidecheck.timer | Starts around 01:50 with up to 2 hours of random delay. Runs as user _aide, with only the capability to read all files. |
| Reports | /var/log/aide/aide.log and the journal | Kept even when mail fails |
Two things changed compared with older Debian releases:
- The daily check is a systemd timer, not cron.
CRON_DAILY_RUNin/etc/default/aideonly applies to systems without systemd. To pause the check, disable the timer instead. - The check no longer runs as root. Root’s local mail used to “just work”. Now the report is only mailed if
s-nailis installed and a local MTA listens on localhost. Otherwise AIDE writes a warning to the journal and the log, and sends nothing. Most upgraded systems silently stopped mailing because of this.
3. Install the packages
apt update
apt install aide s-nail
aide-dynamic is only a transitional package in Debian 13. The normal aide package is what you want.
The host also needs a local MTA listening on localhost:25 that can deliver to security@example.org. Postfix in “satellite” mode, relaying to your mail server, is the usual choice. Check it before relying on AIDE mails:
echo "Mail test from $(hostname -f)" | s-nail -s "Mail test from $(hostname -f)" security@example.orgCode language: PHP (php)
4. Reporting settings
Edit /etc/default/aide and set these values (they’re present but commented out in the shipped file):
# Report recipient
MAILTO=security@example.org
# Daily run: build a new database and report the differences (Debian default)
COMMAND=update
# NEVER copy the new database over the baseline automatically
COPYNEWDB=no
# Mail only when something changed or something went wrong
QUIETREPORTS=yes
# Keep the full details in the mail (the log has them anyway)
TRUNCATEDETAILS=noCode language: PHP (php)
| Setting | Why |
|---|---|
COPYNEWDB=no | The most important line. With yes, every change becomes the new baseline the next day. An intruder’s modification is reported exactly once, in a mail that may get overlooked, and then becomes “trusted”. With no, a change keeps showing up every day until a human accepts it. |
QUIETREPORTS=yes | No daily “nothing changed” mail. When an AIDE mail arrives, it means something. |
COMMAND=update | Writes aide.db.new alongside the report, so accepting reviewed changes is a single copy (section 9) |
Package updates are noisy. Every
apt upgradechanges hundreds of files.FILTERUPDATES=yesandFILTERINSTALLATIONS=yeshide changes that match package operations in the dpkg log. That’s convenient, but an attacker with root can forge log entries too. Leave both onnounless the noise is unmanageable, and accept changes promptly after each patch run instead (section 9).
5. Local rules and exclusions
Debian’s rule set covers the operating system well. What it can’t know is your own applications: caches, uploads, generated files. Without exclusions, they produce daily noise, and noise is how real alerts get ignored.
Debian includes every file from /etc/aide/aide.conf.d/ whose name consists only of letters, digits, _ and -. A file named local.conf is silently ignored because of the dot. Create /etc/aide/aide.conf.d/90_local_rules:
# /etc/aide/aide.conf.d/90_local_rules: site-specific AIDE rules
# "!" excludes a path (regular expression, anchored at the start).
# --- Exclude legitimate churn ------------------------------------------------
# WordPress caches and uploads change all the time
!/var/www/example.org/public/wp-content/cache(/|$)
!/var/www/example.org/public/wp-content/uploads(/|$)
# --- Watch what matters to YOU -------------------------------------------------
# Web application code: content, permissions, owner
/var/www/example.org/public R
# Local admin scripts
/usr/local/sbin RCode language: PHP (php)
R is AIDE’s built-in group for “should never change” files: permissions, inode, links, owner, group, size, mtime, ctime, checksums, ACLs and extended attributes. It doesn’t include the access time, so reading a file never triggers a report.
Check the configuration:
aide --config /etc/aide/aide.conf --config-check && echo "config OK"Code language: PHP (php)
Exclude narrowly.
!/var/wwwwould blind AIDE to a web shell dropped into your document root, which is exactly what it should catch. Exclude the cache directory, not the application.
6. Build the baseline
Build the baseline on a system you trust: freshly installed, fully patched, and before it faces the internet if possible. A baseline taken after a compromise only documents the attacker’s work as “normal”.
aideinit -y -f
This scans the whole system, which takes a few minutes. Then it writes /var/lib/aide/aide.db. Remove the temporary copy so the daily check, which runs as _aide, can create its own:
rm -f /var/lib/aide/aide.db.new
ls -l /var/lib/aide/Code language: PHP (php)
| Option | Meaning |
|---|---|
-y | Overwrite an existing output file without asking |
-f | Overwrite an existing baseline database |
7. Protect the baseline
AIDE can only be trusted as far as its baseline. An attacker with root can modify files and run aide --update to bless the changes. Keep a fingerprint of the baseline somewhere the server can’t write to:
sha256sum /var/lib/aide/aide.db /etc/aide/aide.conf /usr/bin/aide \
| ssh backup.example.org "cat > aide-fingerprints/$(hostname -f)-$(date +%F).sha256"Code language: JavaScript (javascript)
Before you trust a clean report, especially during an incident, compare the current hashes with the stored fingerprint. For the strongest setup, also keep a copy of aide.db itself off-host, and run a check against it from trusted boot media.
Repeat this every time you accept changes (section 9). The fingerprint has to match the baseline in use.
A complementary quick check:
dpkg --verifycompares every installed package file against the checksums from the package database. It’s not a substitute for AIDE (those checksums live on the same host, and config files and non-package files aren’t covered), but it gives an immediate answer to “was any Debian binary replaced?”.
8. The daily check
The timer is enabled on install:
systemctl list-timers dailyaidecheck.timerCode language: CSS (css)
Run a check right now, exactly as the timer would:
systemctl start dailyaidecheck.service
journalctl -u dailyaidecheck.service -n 30 --no-pager
less /var/log/aide/aide.logCode language: JavaScript (javascript)
The service first runs a small helper as root (dailyaidecheck-buildcache.service, which collects LVM data that needs root). It then runs AIDE as the _aide user, with the capability to read every file but write nowhere outside /var/lib/aide and /var/log/aide.
To pause the daily check (for a maintenance window):
systemctl stop dailyaidecheck.timer. Afterwards, runsystemctl start dailyaidecheck.timer. Don’t disable it and forget it.
9. Reviewing and accepting changes
A report lists added, removed and changed entries, with the attributes that differ. Go through it with three questions:
- Is it explained by something I did? A package update (compare with
/var/log/apt/history.log), a config change, a deployment. - Is it expected noise? Add a narrow exclusion (section 5).
- Neither? Treat it as a possible incident. Don’t accept it. Investigate first.
When everything in the report is explained, accept the new state. Because the daily run uses COMMAND=update, the matching new database is already there:
# Make sure aide.db.new is from the run you just reviewed
ls -l --time-style=full-iso /var/lib/aide/aide.db.new /var/log/aide/aide.log
cp /var/lib/aide/aide.db.new /var/lib/aide/aide.dbCode language: PHP (php)
If you changed files after that run (or reviewed an older report), create a fresh report first and review that one:
systemctl start dailyaidecheck.service
less /var/log/aide/aide.log
cp /var/lib/aide/aide.db.new /var/lib/aide/aide.dbCode language: PHP (php)
Then refresh the off-host fingerprint (section 7).
A good rhythm: accept changes right after each patch run or deployment, while you still know exactly what changed. Unaccepted changes pile up quickly, and a report with 400 lines hides the one line that matters.
10. Testing
Prove that AIDE catches a change and that the report reaches you:
# 1. Make a harmless but suspicious-looking change
cp /usr/bin/true /usr/local/sbin/aide-canary
chmod 4755 /usr/local/sbin/aide-canary # a new SUID binary
# 2. Run the daily check
systemctl start dailyaidecheck.service
grep -A3 'aide-canary' /var/log/aide/aide.log # listed as "added"
# 3. Check that the mail arrived at security@example.org
# 4. Clean up, run again: the entry must be gone
rm /usr/local/sbin/aide-canary
systemctl start dailyaidecheck.service
grep -c 'aide-canary' /var/log/aide/aide.log # 0Code language: PHP (php)
If no mail arrives, check the journal for the “not sending mail” warning (section 11).
11. Troubleshooting
| Symptom | Cause / fix |
|---|---|
| No mail, journal says mail isn’t sent | s-nail isn’t installed, or no MTA listens on localhost. Install both (section 3) and test with the s-nail command. |
| Reports list hundreds of changes every day | COPYNEWDB=no is working as designed, but changes aren’t being accepted. Review and accept after each patch run (section 9), and exclude real churn (section 5). |
| My rule file has no effect | Its name contains a dot or another character outside a-z A-Z 0-9 _ - (e.g. local.conf), so Debian skips it. Rename it (90_local_rules). |
aide --config-check fails | A syntax error in your rule file. The message names the file and line. |
Daily run fails: permission denied on aide.db.new | A root-owned aide.db.new left over from a manual run. rm /var/lib/aide/aide.db.new and start the service again. |
Couldn't open file /var/lib/aide/aide.db | No baseline yet. Run aideinit -y -f (section 6). |
| Check takes very long or uses a lot of I/O | Large data directories are being scanned. Exclude bulk data (databases, mail stores, backups) that other tools protect. |
12. Checklist
- โ
aideands-nailare installed, a local MTA delivers tosecurity@example.org, and the mail test arrives - โ
/etc/default/aide:MAILTOset,COPYNEWDB=no,QUIETREPORTS=yes - โ Local rules live in
/etc/aide/aide.conf.d/90_local_rules(no dot in the name), and exclusions are narrow - โ
aide --config-checkpasses - โ The baseline was built on a trusted system (
aideinit -y -f), and the strayaide.db.newwas removed - โ A fingerprint of
aide.db,aide.confand/usr/bin/aideis stored off-host and refreshed after every acceptance - โ
dailyaidecheck.timeris active, and a manual run works and writes/var/log/aide/aide.log - โ The canary test was detected and mailed
- โ Changes are reviewed and accepted after every patch run or deployment, never automatically