متقدم
البحث فيأدلة «كيف»
طريقة البحث
  • اكتب المهمة بكلماتك (find port، open firewall، disk full) أو الصق رسالة الخطأ بين علامتي تنصيص.
  • اختر «الإجابة السريعة» لترى الأوامر فقط، أو مجالًا لتبقى في مجال واحد.
  • "كلمتان" تجد العبارة بالضبط.
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث
جرّب:

كيف 118Security · Audit

How to check file integrity with AIDE

An attacker who gets root often changes system files: a backdoored sshd, a new SUID program, an extra line in /etc/passwd. AIDE takes a fingerprint (checksums, owners, permissions) of important files and later reports every change. This how-to creates the baseline, runs the check daily, reads the report, and updates the baseline after planned changes (patches).

  • 5 الدروس
  • 8 الأوامر

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

$ مستخدم عادي# بصلاحية root (أو مع sudo)

118.1

The quick answer

dnf -y install aide
aide --init
mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
aide --check

On Ubuntu: apt-get install -y aide, then aideinit and aide --config /etc/aide/aide.conf --check.

الأوامر في هذا الدرس

118.2

Step by step

  1. Create the baseline on a clean, freshly installed system (quick answer). --init can take a few minutes.
  2. Run a check — the summary first, then the details:
aide --check
AIDE found differences between database and filesystem!!
Summary:
  Total number of entries:      61234
  Added entries:                1
  Removed entries:              0
  Changed entries:              2
Added entries:
f++++++++++++++++: /usr/local/bin/update-helper
Changed entries:
f   ...    .C... : /usr/sbin/sshd

A changed /usr/sbin/sshd without a patch, or a new file in /usr/local/bin nobody knows = investigate now.

  1. After a planned change (patches, new package), check the report, then make the new state the baseline:
aide --update
mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
  1. What is checked — /etc/aide.conf lists folders and rules. Exclude folders that change all the time:
/etc/aide.conf (part)
!/var/log/.*
!/var/lib/containers/.*
/opt/shop/bin    NORMAL
  1. Run it every day and send the report — a systemd timer (or cron):
/etc/cron.d/aide-check
30 4 * * * root /usr/sbin/aide --check > /var/log/aide/aide-check.log 2>&1 || mail -s "AIDE changes on $(hostname)" ops@example.com < /var/log/aide/aide-check.log
  1. Protect the baseline: an attacker with root can update the database too. Keep a copy of aide.db.gz (and a checksum) off the server and compare from time to time — or use a central tool (Wazuh file integrity monitoring).

الأوامر في هذا الدرس

118.3

Check that it worked

Touch a watched file as a test, run the check, and you see it:

touch /etc/issue
aide --check | grep /etc/issue
f   ...    ..m.. : /etc/issue

118.4

Common problems

ProblemCauseFix
Couldn't open file /var/lib/aide/aide.db.gzNo baseline yet, or not renamed.aide --init, then mv aide.db.new.gz aide.db.gz.
Hundreds of changes every dayLogs, caches, container storage are checked.Exclude them in aide.conf.
Every patch day is "an alert"Baseline not updated after patching.aide --update after reviewed changes (part of the patch routine).
The check takes very longBig folders with full checksums.Exclude data folders; run at night with nice.
Report shows nothing for a known changeThe folder is not in the config.Add it with a rule (NORMAL, PERMS).
Attacker could change the baselineDatabase only on the server.Copy it off the server; compare checksums.

118.5

Go further

1Why create the AIDE baseline on a freshly installed system?

The baseline is "the good state"; if the system is already changed by an attacker, AIDE treats that as normal.

2What must you do after patching, so AIDE does not report the updates every day?

Review the report, then aide --update and replace the database with the new one.

كل الأوامر في هذا الفصل