Sub topic 4
Scanning with OpenSCAP and Reading the Results
Assume you can use the Linux command line, edit files, run systemctl and journalctl, and use sudo. You also need a test RHEL 9 server or virtual machine. Do not test remediation commands on a production host until you understand their effect.
OpenSCAP is a tool for evaluating a system against security content written in the Security Content Automation Protocol (SCAP). SCAP content contains rules, profiles, checks, and expected results. The Security Guide (SSG) project publishes much of the content used with RHEL systems.
Select the Correct Content and Profile
A benchmark is a set of security recommendations. A profile is a selected group of those recommendations. For example, a server profile may differ from a workstation profile. Level 1 usually targets practical, lower-risk controls. Level 2 adds stricter controls that can affect compatibility or operations.
Start by inspecting the content installed on the host:
oscap info /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xmlLook for the profile ID that matches your operating system, server role, and policy. Do not assume that every SSG release contains an official CIS profile. Profile names and available content vary by distribution and package version.
Run a Baseline Scan
Run the scan as a read-only assessment. This command writes both a machine-readable results file and an HTML report:
sudo oscap xccdf eval \
--profile xccdf_org.ssgproject.content_profile_cis_server_l1 \
--results results.xml \
--report report.html \
/usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xmlThe command may return a nonzero status when rules fail. That does not necessarily mean the scan crashed. Open report.html in a browser and keep results.xml for later comparison or automation.
Read Findings Before Changing Anything
| Result | Meaning | First response |
|---|---|---|
| Pass | The check found the expected state | Record it as compliant |
| Fail | The observed state differs from the rule | Review the rule and business impact |
| Not applicable | The rule does not apply to this host | Confirm the reason |
| Error | The check could not run correctly | Fix the scan or content problem |
A failed rule normally includes a rationale, expected value, detected value, and remediation guidance. Read the rationale before applying the suggested command. A rule can fail because a service is intentionally required, a mount point has a workload-specific option, or the scanner cannot understand a local configuration.
Separate automated checks from manual checks. OpenSCAP can inspect many files, packages, permissions, services, and kernel values. It cannot reliably decide whether a documented exception is acceptable, whether an application needs a port, or whether a change has been tested. Treat the report as evidence for a decision, not as permission to apply every fix.
Exercise
Exercise
A scan reports that SSH permits root login. What should you do before changing the setting?
Show answer
Read the rule and rationale, confirm that your access uses a separate administrative account, check the effective SSH configuration with sshd -T, and test the change on a nonproduction host or through a console.