Advanced
Searching inInstall guides
How to search
  • Paste an error message in quotes, e.g. "permission denied", to find the fix table that explains it.
  • Choose an area and a part of the guide (install, first settings, daily use, security, fixes) to go straight to the right step.
  • "two words" finds the exact phrase.
  • Plain words find names, texts and examples.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search
Try:

Guide 74OpenSCAP · Security

Install and use OpenSCAP (compliance scans)

OpenSCAP checks a Linux system against a security standard — CIS Benchmarks, DISA STIG, PCI DSS, ANSSI, Essential Eight — and writes an HTML report with every rule, pass or fail, and how to fix it. It can also create Ansible or Bash fixes for the failures, scan for known CVEs, and scan container images. It is Red Hat's standard compliance tool and part of the RHEL tooling. This guide installs OpenSCAP and the SCAP Security Guide content, runs a CIS scan, generates and applies remediation safely, tailors the profile, and scans for CVEs.

  • 11 Lessons
  • 10 Commands

$ run as a normal user# run as root (or with sudo)

74.1

Know it before you install

A data stream file (ssg-rhel9-ds.xml) holds rules and profiles (a profile = a set of rules for one standard and level). oscap xccdf eval checks the system against one profile. Tailoring turns rules on/off or changes values for your company. OVAL content checks CVEs against installed packages.

ItemValue
Packages (RHEL)openscap-scanner (the oscap tool), scap-security-guide (content)
Content/usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml (RHEL 9), …-rhel10-ds.xml
Ubuntuopenscap-scanner (or openscap-utils) + content from the ComplianceAsCode releases
Profiles (examples)cis_server_l1, cis_server_l2, stig, pci-dss, anssi_bp28_high, e8
Outputsresults XML (ARF), HTML report, Ansible/Bash fix scripts

Commands in this lesson

74.2

Install on RHEL, Rocky and Alma

dnf -y install openscap-scanner scap-security-guide
ls /usr/share/xml/scap/ssg/content/ | grep ds.xml
ssg-rhel9-ds.xml
oscap info /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml | grep -A1 'Id: xccdf_org.ssgproject.content_profile' | head -20

74.3

Install on Ubuntu and Debian

apt-get update
apt-get install -y openscap-scanner unzip
curl -fsSLO https://github.com/ComplianceAsCode/content/releases/download/v0.1.78/scap-security-guide-0.1.78.zip
unzip -q scap-security-guide-0.1.78.zip
ls scap-security-guide-0.1.78/ | grep -i ubuntu
ssg-ubuntu2404-ds.xml

(Choose the newest content release. On Ubuntu the package may be called openscap-utils in some versions. Canonical's Ubuntu Pro also offers the Ubuntu Security Guide usg.)

74.4

First configuration: a CIS scan

DS=/usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml
oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_cis_server_l1 --results-arf /root/cis-arf.xml --report /root/cis-report.html $DS
Title   Ensure /tmp Located On Separate Partition
Rule    xccdf_org.ssgproject.content_rule_partition_for_tmp
Result  fail
…

Open cis-report.html in a browser: score, every failed rule, the reason, and the fix (Bash/Ansible) for each rule. Exit code 2 = some rules failed (normal for a first scan).

OptionWhy
--profileWhich standard and level (use the full ID from oscap info).
--results-arfMachine-readable results (for tools, Red Hat Insights/Satellite, evidence).
--reportThe HTML report for people and auditors.
--tailoring-fileYour company's changes to the profile (below).

Commands in this lesson

74.5

Fix the findings safely

Generate an Ansible playbook for the failed rules only, review it, test it on a non-production server, then apply:

oscap xccdf generate fix --fix-type ansible --result-id "" --output /root/cis-fix.yml /root/cis-arf.xml
less /root/cis-fix.yml
ansible-playbook -i test-web1, /root/cis-fix.yml --check
ansible-playbook -i test-web1, /root/cis-fix.yml

Or a playbook for the whole profile (for golden images with Packer):

oscap xccdf generate fix --fix-type ansible --profile xccdf_org.ssgproject.content_profile_cis_server_l1 --output cis-l1.yml $DS

Watch out

oscap xccdf eval --remediate changes the system at once. Some rules (SSH settings, partitions, password rules, FIPS, audit) can lock users out or break apps. Always test fixes on a copy first and keep console access.

74.6

Tailor the profile

Your company may accept some failures (for example no separate /tmp partition on cloud VMs). Make a tailoring file instead of ignoring the report:

autotailor --output tailoring.xml --new-profile-id cis_server_l1_company --unselect partition_for_tmp --unselect partition_for_var_log_audit --var-value var_password_pam_minlen=14 $DS cis_server_l1
oscap xccdf eval --tailoring-file tailoring.xml --profile cis_server_l1_company --report /root/cis-company.html $DS

(autotailor comes with the OpenSCAP utilities; the SCAP Workbench GUI can do the same.) Keep the tailoring file in Git with the reasons.

Commands in this lesson

74.7

Daily use: CVE scans, images and the real uses

CVE scan with Red Hat's OVAL data:

curl -fsSLO https://security.access.redhat.com/data/oval/v2/RHEL9/rhel-9.oval.xml.bz2
bunzip2 rhel-9.oval.xml.bz2
oscap oval eval --report /root/cve-report.html rhel-9.oval.xml

More:

oscap info $DS
oscap-ssh root@web2 22 xccdf eval --profile xccdf_org.ssgproject.content_profile_cis_server_l1 --report web2.html $DS
oscap-podman registry.example.com/shop:1.4.0 xccdf eval --profile xccdf_org.ssgproject.content_profile_standard --report image.html $DS

Real uses at work:

  • Prove compliance (CIS, STIG, PCI DSS) with reports for audits.
  • Harden golden images: run the Ansible fix in Packer, scan the result.
  • Install RHEL already compliant (security profile in the installer/Kickstart).

74.8

Make it safe

Security checklist:

  • Scan regularly (monthly or after changes) and keep reports as evidence.
  • Fix with reviewed Ansible playbooks, tested on non-production first — not blind --remediate.
  • Tailor with written reasons; review the tailoring file each year.
  • Keep scap-security-guide updated (new rules, new benchmark versions).
  • Reports show weaknesses — store them privately.

74.9

Update and remove

dnf -y upgrade openscap-scanner scap-security-guide
dnf -y remove openscap-scanner scap-security-guide

Commands in this lesson

74.10

Fix common problems

ProblemCauseFix
No profile matching suffix "cis" was foundWrong profile ID for this content.oscap info DS-FILE and copy the exact ID.
Many rules notapplicableContent for another OS version.Use the data stream for your exact OS (rhel9 vs rhel10, ubuntu2204 vs 2404).
SSH login broken after remediationA hardening rule changed SSH or PAM.Console access; restore the config; test fixes first; tailor the rule.
Scan is very slowRules that walk the whole file system.Normal for some rules; run off-hours.
Ubuntu: no contentscap-security-guide is not packaged there.Download the ComplianceAsCode release (or use usg).

Commands in this lesson

74.11

Next steps

1Why use generate fix --fix-type ansible instead of --remediate?

You can review and test the playbook first; --remediate changes the system at once.

2Your cloud VMs can not have a separate /tmp partition. How do you handle the failing rule?

Unselect it in a tailoring file with a written reason, and scan with that tailored profile.

Commands in this lesson

All commands in this chapter