How to Install & Config AIDE (Advanced Intrusion Detection Environment)

luthfiemka's avatar By luthfiemka on
Featured Image

Advanced Intrusion Detection Environment (AIDE) is an open-source file integrity monitoring tool for Linux systems, designed to detect unauthorized changes to files, configurations, or binaries. Similar to tools like Tripwire, AIDE is lightweight, fast, and straightforward to configure, making it a valuable component for securing servers against silent threats such as backdoors or unauthorized modifications.

Overview

AIDE works by creating a baseline database of file attributes (e.g., permissions, checksums, timestamps) and comparing it against the current state of the system to identify changes. It is particularly effective for detecting subtle malicious activities, such as:

  • Modified system binaries (e.g., /bin/ls, sshd)
  • Unauthorized cron jobs
  • Suspicious scripts in directories like /tmp, /var/tmp, or /dev/shm

By alerting administrators to these changes, AIDE helps mitigate risks that might otherwise go unnoticed without active monitoring.

Installation

AIDE can be installed on various Linux distributions using their respective package managers.

Ubuntu/Debian

sudo apt update
sudo apt install aide

Red Hat/CentOS/AlmaLinux

sudo yum install aide

Note: Ensure the package manager is up-to-date before installation to avoid dependency issues. On some systems, additional repositories (e.g., EPEL for CentOS) may be required for AIDE installation.

Initializing the AIDE Database

After installation, AIDE requires an initial database to serve as the baseline for file integrity checks. To create this database, run:

sudo aideinit

This command generates a database (typically stored in /var/lib/aide/aide.db) containing cryptographic checksums and metadata for monitored files. The initialization process may take some time, depending on the number of files and directories included in the configuration.

Note: The aideinit command may vary slightly by distribution. For example, some systems require running aide --init instead. Always consult the documentation for your specific distribution.

Configuration

AIDE’s configuration file, typically located at /etc/aide/aide.conf, allows administrators to customize which files and directories to monitor, as well as the attributes to check (e.g., file size, permissions, SHA256 checksums). A sample configuration might include:

# Monitor system binaries
/bin Normal
/usr/bin Normal
# Monitor configuration files
/etc R
# Exclude temporary directories
!/tmp
!/var/tmp
!/dev/shm
  • Normal: Checks permissions, inode, size, and checksums.
  • R: Read-only checks for configuration files.
  • !: Excludes specified directories from monitoring.

Additional Info: Regularly review and update the configuration to balance security and performance. Monitoring too many files can slow down checks, while excluding critical directories may leave vulnerabilities.

Usage

To perform a file integrity check, run:

sudo aide --check

This compares the current file system against the baseline database and reports discrepancies. If changes are detected, AIDE generates a detailed report, which can be reviewed to identify potential security issues.

Tip: Automate AIDE checks using cron jobs to ensure regular monitoring. For example, add the following to /etc/crontab for daily checks:

0 2 * * * root /usr/bin/aide --check > /var/log/aide/aide.log

Additional Notes

  • Performance: AIDE is resource-efficient but may impact system performance on large file systems. Schedule checks during low-usage periods to minimize disruption.
  • Security: Store the AIDE database on a read-only medium or a separate, secure system to prevent tampering by attackers.
  • Alternatives: While AIDE is free and effective, other tools like Tripwire, Samhain, or OSSEC offer similar functionality with different trade-offs. AIDE’s simplicity makes it ideal for small to medium-sized deployments.
  • Updates: After legitimate system changes (e.g., package upgrades), update the AIDE database using aide --update to prevent false positives.

References