Toward a standards-compliant, tightly locked AlmaLinux system: scanning and applying policy with OpenSCAP, the CIS Benchmarks and STIG baselines, security audits with lynis, file integrity monitoring with AIDE, and the ClamAV antivirus for certain workloads.

In the previous episode, Episode 15, we built the encryption foundation with TLS and PKI. Now we go up a level: making sure the system isn't just secure by feeling, but compliant with auditable standards. For organizations handling sensitive data — finance, healthcare, government — this compliance isn't a choice, it's an obligation.
This episode introduces OpenSCAP and security baselines, audit tools, integrity monitoring, and antivirus for certain workloads.
OpenSCAP is a tool ecosystem for automating security compliance based on the SCAP (Security Content Automation Protocol) standard. AlmaLinux provides official security content you can use directly.
sudo dnf5 install -y openscap-scanner scap-security-guideThe scap-security-guide package ships industry-standard security profiles. See the profiles available for AlmaLinux:
oscap info /usr/share/xml/scap/ssg/content/ssg-almalinux9-ds.xml | head -40The output shows the list of ready-to-use profiles, including CIS and STIG.
Run a compliance scan against one profile:
sudo oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_cis \
--results-arf /tmp/scan-results.xml \
/usr/share/xml/scap/ssg/content/ssg-almalinux9-ds.xmlThe results are saved in ARF (Asset Reporting Format). For a human-readable report:
oscap xccdf generate report /tmp/scan-results.xml -o /tmp/scan-report.htmlOpenSCAP can fix findings automatically, not just report them:
sudo oscap xccdf eval --remediate \
--profile xccdf_org.ssgproject.content_profile_cis \
/usr/share/xml/scap/ssg/content/ssg-almalinux9-ds.xmlWarning
--remediate changes real system configuration. Run it in a staging environment first, and read the scan results before applying in production — some remediations can disable services or change behavior in unexpected ways.
Two frameworks you'll encounter most often:
| Baseline | Publisher | Focus |
|---|---|---|
| CIS Benchmarks | Center for Internet Security | Best-practice hardening, tiered into Level 1 and 2 |
| STIG | DoD (United States) | Mandatory security standard for military/government environments |
The CIS profile in scap-security-guide covers password settings, auditing, SSH, and much more. STIG is stricter and mandatory for systems handling US government data.
To apply hardening consistently across many servers, use Ansible. The almalinux-hardening playbook is a collection of automation that applies AlmaLinux best practices:
sudo dnf5 install -y ansible-coreAnsible playbooks use variables that can be tuned per environment, and run over SSH — the infrastructure we already secured in episode 14. This "hardening as code" approach makes your security policy reviewable, testable, and reproducible.
lynis is an open-source security audit tool that analyzes the system and gives a score:
sudo dnf5 install -y epel-release
sudo dnf5 install -y lynis
sudo lynis audit systemLynis checks hundreds of security controls, then shows a score and recommendations. Although it's not a replacement for OpenSCAP in formal compliance, lynis is very useful as a quick check and an educational narrative for finding missed gaps.
AIDE (Advanced Intrusion Detection Environment) detects changes to important files by building a hash database:
sudo dnf5 install -y aideInitialize the first database:
sudo aide --init
sudo mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gzAfter that, routine checks compare the current state against the database:
sudo aide --checkInfo
The correct production pattern: update the database after legitimate system changes (upgrades, software additions), then schedule periodic checks via cron or a systemd timer (episode 12). File changes without the database being updated are an alarm signal.
For workloads that need malware scanning — such as mail servers or file sharing — install ClamAV:
sudo dnf5 install -y clamav clamav-update
sudo systemctl enable --now clamd@scanUpdate the virus database periodically:
sudo freshclam
clamscan -r /srv/filesClamAV is optional on pure Linux servers — but important when a server accepts files from external users. Combine it with AIDE: ClamAV detects incoming malware, AIDE detects unauthorized system changes.
Don't forget the foundation we built in episode 9:
sudo firewall-cmd --get-active-zones
sudo firewall-cmd --list-allA firewall that only opens necessary services, uses the right zones, and has no rogue ports is the first item on the hardening checklist — and usually also the first item to fail an OpenSCAP scan.
--remediate without reading scan results. Remediation can disable services — test in staging first.aide.db.new.gz. A database in the wrong location makes aide --check fail with confusing results.In this episode 16 you've built a standards-compliant, locked-down system: scanning and remediation with OpenSCAP, understanding the CIS and STIG baselines, hardening automation with Ansible, auditing with lynis, integrity monitoring with AIDE, and ClamAV for certain workloads.
Key takeaways:
--remediate fixes findings automatically — test in staging before production.almalinux-hardening playbook automate mass hardening.Compliance is a journey, not a one-time destination. In the next episode, Episode 17, we'll cover Performance Tuning & Resource Management — tuning profiles with tuned-adm, systemd resource limits with cgroups v2, and performance analysis with systemd-analyze. See you there!