Join our Newsletter — 33% off our NHI Course
Home› Guides› Linux File Integrity Monitoring Guide: Choosing and Running…
Guide Endpoint Security

Linux File Integrity Monitoring Guide: Choosing and Running AIDE, IMA/EVM and Keylime

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 27 October 2026 17 min read
On this page

File integrity monitoring on Linux usually means a nightly AIDE run that nobody reads, which tells you a binary changed only after an attacker has already used it. Linux has three very different integrity layers: AIDE compares files against a stored baseline, the kernel's Integrity Measurement Architecture (IMA) and Extended Verification Module (EVM) measure and appraise files as they are opened, and Keylime uses the TPM to prove those measurements to a remote verifier. Used together they move you from "detect later, on the same host the attacker controls" to "prevent or prove, from somewhere else". This guide explains how each layer works, what to monitor, how to roll them out without breaking patching, and how they meet PCI DSS and NIST SI-7 requirements. It is for Linux platform engineers, detection engineers and auditors; basic AIDE set-up is covered in the Linux Server Hardening Guide and is not repeated here.

Key takeaways

  • AIDE detects, IMA can prevent. Red Hat's own comparison is that AIDE detects modifications on the local system only, while IMA can detect and prevent changes and can support remote verification.
  • A baseline on the attacked host is not evidence. If the AIDE database, configuration and binary live on the same writable disk as the files they check, root can rewrite all three; keep them read-only or off-host.
  • Remote attestation removes the trust problem. Keylime has the TPM sign the IMA measurement list (PCR 10) and boot log, so a verifier on another host decides whether the machine is still in a known state.
  • Change detection is only as good as change control. Every package update changes hundreds of files; without a link from FIM alerts to approved changes, alerts are either ignored or the baseline is updated blindly.
  • Integrity is not trustworthiness. FIM tells you a file differs from the baseline, not whether the baseline was clean: a backdoored package installed through normal patching passes every check.

The three layers and when to use each

LayerHow it worksWhen it checksCan it block?Trust anchorBest fit
AIDEHashes and attributes of selected paths compared with a stored databaseOn schedule (cron or systemd timer)NoThe database and binary, wherever you store themEvery server; compliance evidence; configuration drift
Package verificationCompare installed files with the package manager's recorded digests (for example rpm -Va)On demandNoSigned package metadata in the local databaseQuick triage of system binaries after an alert
IMA measurementKernel hashes files on exec, mmap or open per policy and appends to a measurement list, extending TPM PCR 10Every access covered by policyNo (measure only)TPM, if presentFeeding remote attestation; forensic record of what ran
IMA appraisal and EVMKernel compares a file's hash or signature in security.ima with its content, and EVM protects the security extended attributesEvery access covered by policyYes, in enforce modeKeys on the .ima and .evm keyringsImmutable appliances, high-assurance servers, signed builds
KeylimeRemote verifier checks TPM quotes against the IMA log and measured boot log using a runtime policyContinuously (polling)Indirectly, through revocation actionsTPM endorsement keys and your CAFleets that must prove state to someone other than the host

Decision guidance

  • Small estate, general servers: AIDE with an off-host database and a SIEM alert on non-zero exit status covers most compliance needs. Add package verification to your triage runbook.
  • Regulated or high-value servers: add IMA measurement and Keylime so the integrity decision is made off the host. This needs a TPM 2.0 (physical or, with caveats, virtual) and a verifier service.
  • Immutable or appliance-like systems: IMA appraisal in enforce mode is realistic only where you control the build and can sign every executable; general-purpose servers that install third-party software usually stay in measurement or log mode.
  • Containers and short-lived VMs: per-instance AIDE baselines add little; verify the image at build and admission time, and use IMA and Keylime on the long-lived hosts that run them. See the Server Build and Golden Image Hardening Guide.

Running AIDE properly

What to watch

The AIDE configuration (/etc/aide.conf on RHEL) is a set of rules: a path regular expression followed by an attribute group. AIDE defines default groups, for example R (permissions, file type, inode, links, owner, group, size, mtime, ctime, a hash and extended attributes), L (the same without content hash, for logs) and > for growing files. Rules can exclude paths with ! (recursive) and, in AIDE 0.19 and later, - (non-recursive). Every rule must start with an explicit /.

Path classExamplesSuggested groupAttack it reveals
System binaries and libraries/usr/bin, /usr/sbin, /usr/lib64, /bootFull content hash (R)T1554 Compromise Host Software Binary, T1014 Rootkit
Loader and preload configuration/etc/ld.so.preload, /etc/ld.so.conf.dFull content hashT1574.006 Dynamic Linker Hijacking
Identity and authentication files/etc/passwd, /etc/shadow, /etc/sudoers.d, /etc/pam.d, /etc/ssh/sshd_configFull content hashBackdoor accounts, PAM modules, SSH configuration changes
Keys and credentials/root/.ssh/authorized_keys, service account authorized_keys, keytabsFull content hashT1098.004 SSH Authorized Keys
Persistence locations/etc/systemd/system, /etc/cron.d, /var/spool/cron, /etc/modules-load.dFull content hashT1543.002 Systemd Service, T1053.003 Cron, T1547.006 Kernel Modules
Application code and web roots/opt/<app>, /var/wwwFull content hash, with exclusions for caches and uploadsWeb shells, tampered application code
Logs/var/logGrowing (>) or L, never full hashTruncation or deletion of logs

Service account keys and keytabs are non-human credentials: an unexpected new authorized_keys entry for a deployment account is as serious as a new root password. See the Linux Service Accounts and Keytab Management Guide and the SSH Key Management Guide.

Making results usable

  • Exit status: aide --check returns 1 for new files, 2 for removed files and 4 for changed files, added together (so 7 means all three), with 14 to 25 reserved for errors such as configuration (17) or database (24) problems. Alert on any non-zero value, and treat error codes as a monitoring failure, not a clean result.
  • Output to the SIEM: report_url can write to a file or to syslog:<facility>, and newer AIDE releases (0.18 and later) support report_format=json or ndjson, which parse far more reliably than plain text. Check the version your distribution ships.
  • Frequency: Red Hat states that at a minimum AIDE should run weekly, and daily is better. Its example cron entry is 05 4 * * * root /usr/sbin/aide --check.
  • Protect the baseline: store the database, configuration and /usr/sbin/aide on read-only media or pull them from a central store at check time. The rhel-system-roles.aide Ansible role can initialise the database and fetch it to the control node (aide_db_fetch_dir), which keeps the trusted copy off the host.
  • Update deliberately: aide --update writes a new database that only takes effect when you rename it. Run it after verifying the change, from the same pipeline that applied the change, never as a reflex to silence alerts.

IMA and EVM: integrity in the kernel

How IMA works

IMA is configured with a policy of rules in the form action [condition ...], where actions include measure, appraise, audit and their dont_ forms, and conditions include hooks such as BPRM_CHECK (program execution), FILE_MMAP or MMAP_CHECK (executable mappings), FILE_CHECK, MODULE_CHECK, FIRMWARE_CHECK, KEXEC_KERNEL_CHECK and KEY_CHECK. Measurements are listed in /sys/kernel/security/ima/ascii_runtime_measurements, and on a system with a TPM each one extends PCR 10, which makes the list tamper-evident.

Kernel parameterValues (kernel documentation)Meaning
ima_policy=tcb, appraise_tcb, secure_boot, fail_securely, critical_datatcb measures executed programs, executable mappings and files read by root; appraise_tcb appraises files owned by root; secure_boot appraises kexec images, modules, firmware and policy by signature
ima_appraise=off, enforce, fix, log (default enforce)fix labels files without blocking; log records failures; enforce denies access to files that fail appraisal
ima_template=ima, ima-ng, ima-ngv2, ima-sig, ima-sigv2 (default ima-ng)ima-sig includes file signatures in the log so a verifier can check them
ima_hash=For example sha256, sha512 (kernel default sha1)Set an explicit modern algorithm; signatures must use the same algorithm IMA measures with
evm=fixPermits security.evm to be updated regardless of integrity status, for initial labelling

Appraisal and signatures

  • Hash or signature: appraisal compares file content with the value stored in the security.ima extended attribute. A plain hash only proves the file has not changed since labelling; a signature (appraise_type=imasig, appended modsig or format v3 sigv3) proves who approved it.
  • Signing: files are signed with evmctl ima_sign from the ima-evm-utils package, and the public key must be loaded on the .ima keyring. Keylime's documentation warns that signing with a different hash algorithm from the one IMA measures with produces invalid signatures.
  • EVM: protects security extended attributes (including security.ima and SELinux labels) against offline tampering, either with an HMAC from a trusted or encrypted key in the kernel keyring or with an asymmetric signature. Setting bit 31 in <securityfs>/evm prevents further runtime change of the EVM policy.
  • fs-verity: the policy option digest_type=verity lets IMA use an fs-verity file digest instead of a full file hash, which suits large read-only files.

The signing keys are the root of trust for the whole fleet. Hold them in an HSM or a tightly controlled signing service, not on build agents. See the Linux Package Signing and Repository Trust Guide.

Keylime: remote attestation for Linux fleets

Keylime moves the integrity decision off the monitored host. Red Hat Enterprise Linux 9 documents four parts: an agent on each monitored system, a verifier that performs initial and periodic checks, a registrar that holds the agent database and TPM vendor public keys, and the keylime_tenant utility used to provision agents and policies.

ComponentRHEL 9 package and default portSecurity notes
Verifierkeylime-verifier, TCP 8881, configuration in /etc/keylime/verifier.conf.d/Control interface uses mutual TLS; by default it generates its CA under /var/lib/keylime/cv_ca/, which you should replace with your own PKI for production
Registrarkeylime-registrar, TCP 8890 for agents and 8891 (TLS) for verifier and tenantDatabase defaults to SQLite; PostgreSQL, MySQL and MariaDB are supported for scale
AgentRuns on each monitored host with access to the TPMReports TPM quotes, the IMA log and the boot event log
Tenantkeylime_tenantWhoever can run it with valid certificates can change runtime policies: treat it as privileged
  • Runtime integrity: the verifier checks the IMA measurement list against a runtime policy (formerly called an allowlist) of expected hashes plus an exclude list of regular expressions, and validates it against TPM quotes of PCR 10. A file not in the policy, or a file with the wrong hash, puts the agent into a failed state.
  • Measured boot: with a measured boot reference state, the agent also sends /sys/kernel/security/tpm0/binary_bios_measurements, the verifier replays it against PCRs 0 to 9 and 11 to 14, and compares it with the reference using a measured boot policy.
  • Policy creation is the hard part: Keylime's documentation advises generating the policy in a secure, ideally isolated environment and signing it. Build it from your signed packages and image pipeline, not from a running production host that may already be compromised.
  • Virtual TPMs: Red Hat notes that Keylime in a VM or with a virtual TPM depends on the integrity of the underlying host.
  • Machine identity: each agent is a non-human identity with a TPM-bound key and a certificate; enrolment, renewal and revocation of agent certificates need an owner. See the IoT Device Identity with TPM and DICE Guide.

Implementation roadmap

  1. Scope and baseline (weeks 1 to 2): classify servers by tier, list the critical paths per role using the table above, and write an AIDE configuration per role. Store the configuration in version control.
  2. AIDE everywhere (weeks 2 to 6): deploy with configuration management, initialise the database from a freshly built, patched host, keep the trusted copy off-host, and schedule daily checks. Forward exit codes and reports to the SIEM.
  3. Connect to change control: have the patching or deployment pipeline run aide --check before a change and aide --update after verification, attaching the diff to the change record. Unexplained differences become incidents.
  4. IMA measurement pilot: on a pilot ring, boot with ima_policy=tcb or a custom policy loaded from /etc/ima/ima-policy, set ima_hash=sha256, and measure the performance cost and log volume for a full business cycle.
  5. Keylime for high-value tiers: deploy the verifier and registrar on hardened hosts with your own CA, generate runtime policies from the image pipeline, start with alerting only, then define revocation actions (for example removing the host from a load balancer or revoking its certificates).
  6. Appraisal where you control the build: sign executables in the build, run ima_appraise=fix to label, then log to find unsigned or failing files, and only then enforce.
  7. Rollback: keep a boot entry without the IMA appraisal parameters and test console access before enforcing; for Keylime, removing an agent with keylime_tenant -c delete stops attestation without touching the host. Never roll back by updating the baseline from the suspect host.

Detection and measurement

  • Alert on: AIDE changes outside a change window; AIDE error exit codes or missing reports (the check itself was disabled, which maps to ATT&CK T1685 Disable or Modify Tools); Keylime agent failed states; new authorized_keys entries; changes to /etc/ld.so.preload; unexpected kernel module measurements.
  • Correlate with auditd: AIDE says what changed, auditd watch rules on the same paths say who changed it and with which process. See the Linux Logging and auditd for Defenders Guide.
  • Triage quickly: on an alert, compare the file with its package (rpm -Vf <file> or the distribution equivalent), check the IMA log for when it was first executed, and preserve the host before updating anything. See the Linux Forensics Guide.

Metrics

  • Coverage: percentage of in-scope servers with a successful integrity check in the last 24 hours (target 100 percent for PCI and Tier 0).
  • Silent failures: number of hosts whose check returned an error code or no report (target zero, investigated within one day).
  • Explained change rate: percentage of integrity differences matched to an approved change record (trend towards 100 percent).
  • Time to triage: median time from an unexplained difference to a decision (benign or incident).
  • Attested fleet: percentage of high-value servers under Keylime attestation with a runtime policy built from the pipeline.

Framework and compliance mapping

RequirementWhat it asksLinux control
PCI DSS v4.0.1 Requirement 11.5.2A change-detection mechanism such as FIM that alerts on unauthorised modification of critical files and compares them at least weeklyAIDE daily with SIEM alerting; Keylime for continuous checks
NIST SP 800-53 Rev 5 SI-7, SI-7(1), SI-7(6), SI-7(7)Integrity verification, integrity checks, cryptographic protection, integration with incident responseAIDE hashes; IMA signatures; FIM alerts feeding the incident process
NIST SP 800-53 Rev 5 SI-7(9)Verify boot processSecure Boot plus Keylime measured boot attestation
NIST SP 800-53 Rev 5 CM-3, AU-9Configuration change control; protection of audit informationLinking updates to change records; FIM on log configuration
NIST CSF 2.0 PR.DS-01, PR.PS-01, DE.CM-09Data at rest integrity, configuration management, monitoring of software and runtime environmentsAll three layers
CIS Controls v8.1Control 4 Secure Configuration; Control 8 Audit Log ManagementBaselines and logging of integrity results
ISO/IEC 27001:2022 Annex AA.8.9 Configuration management; A.8.16 Monitoring activitiesBaselines and alerting
MITRE D3FENDD3-FIM File Integrity Monitoring; D3-TBI TPM Boot IntegrityAIDE and IMA; Keylime measured boot

For the broader secure boot chain that IMA and Keylime build on, see the Linux Secure Boot and Shim Guide.

Common failure patterns

  • Baseline on the same disk: the AIDE database and binary are writable by root on the host, so an attacker with root updates the baseline after planting a backdoor and every later check is clean.
  • Reflex updates: operators run aide --update after every alert to make it go away, which turns FIM into a record of whatever the attacker left behind.
  • Checking the wrong paths: the default configuration covers system binaries but not /opt applications, web roots or service account authorized_keys, which is where real intrusions persist.
  • Silent failure treated as success: a cron job that stopped, a database that failed to load (exit code 24) or a report that never reached the SIEM looks exactly like "no changes" unless you alert on missing results.
  • Allowlists built from production: generating a Keylime runtime policy or AIDE baseline from a live host bakes any existing compromise into the trusted state.
  • Enforcing IMA appraisal too early: switching to ima_appraise=enforce before every executable, library and module is signed leaves a server unable to boot or run its software.

Lessons from incidents

The XZ Utils backdoor shows the limit of file integrity monitoring. The malicious code shipped inside signed, legitimate release tarballs for XZ Utils 5.6.0 and 5.6.1, so a system updated through normal package channels would have recorded the backdoored liblzma as its new, trusted baseline. AIDE and IMA would both have reported the file as changed during the update and then accepted it. FIM proves that files match what you approved; it cannot tell you that what you approved was clean. That job belongs to supply chain controls, reproducible builds and behavioural detection (the backdoor was found through unusual CPU use during SSH logins). See the Software Supply Chain Security Guide.

Practitioner checklist

  • Define critical paths per server role, including /opt applications, web roots, service account keys and persistence locations.
  • Initialise AIDE baselines from freshly built hosts and keep the database, configuration and binary off-host or read-only.
  • Run AIDE at least daily, send JSON or syslog output to the SIEM and alert on any non-zero exit code and on missing reports.
  • Run aide --update only from the change pipeline after verification, attaching the diff to the change record.
  • Pilot IMA measurement with ima_hash=sha256 and measure the performance and log impact before wider use.
  • Deploy Keylime for high-value tiers with your own CA and runtime policies built from the image pipeline.
  • Sign executables in the build and move IMA appraisal through fix and log before enforce.
  • Protect IMA and EVM signing keys in an HSM or controlled signing service.
  • Correlate integrity alerts with auditd and package verification in a written triage runbook.
  • Report coverage, silent failures and explained change rate monthly.

Standards and references

Related NHI Mgmt Group resources: Linux Server Hardening Guide · Red Hat Enterprise Linux Security Hardening Guide · fapolicyd and Linux Application Allowlisting Guide · Linux Detection and Response Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 27 October 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.