$ run as a normal user# run as root (or with sudo)
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.
| Item | Value |
|---|---|
| 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 |
| Ubuntu | openscap-scanner (or openscap-utils) + content from the ComplianceAsCode releases |
| Profiles (examples) | cis_server_l1, cis_server_l2, stig, pci-dss, anssi_bp28_high, e8 |
| Outputs | results XML (ARF), HTML report, Ansible/Bash fix scripts |
Install on RHEL, Rocky and Alma
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.)
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).
| Option | Why |
|---|---|
--profile | Which standard and level (use the full ID from oscap info). |
--results-arf | Machine-readable results (for tools, Red Hat Insights/Satellite, evidence). |
--report | The HTML report for people and auditors. |
--tailoring-file | Your company's changes to the profile (below). |
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.ymlOr 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 $DSWatch 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.
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.
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.xmlMore:
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 $DSReal 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).
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-guideupdated (new rules, new benchmark versions). - Reports show weaknesses — store them privately.
Update and remove
Fix common problems
| Problem | Cause | Fix |
|---|---|---|
No profile matching suffix "cis" was found | Wrong profile ID for this content. | oscap info DS-FILE and copy the exact ID. |
Many rules notapplicable | Content for another OS version. | Use the data stream for your exact OS (rhel9 vs rhel10, ubuntu2204 vs 2404). |
| SSH login broken after remediation | A hardening rule changed SSH or PAM. | Console access; restore the config; test fixes first; tailor the rule. |
| Scan is very slow | Rules that walk the whole file system. | Normal for some rules; run off-hours. |
| Ubuntu: no content | scap-security-guide is not packaged there. | Download the ComplianceAsCode release (or use usg). |
Next steps
- Quick how-tos: Find files with risky permissions, Harden the SSH server, Scan a server against CIS.
- Command page: oscap.
- At work: OpenSCAP — compliance profiles. A quicker audit: Lynis.
- Apply fixes: Ansible. Bake them into images: Packer. Watch drift: Wazuh SCA.
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.