CIS Security Baseline: Linux Server Hardening Standard
CIS Benchmarks are consensus-based configuration standards maintained by cybersecurity experts worldwide, covering more than 25 product families. They include mainstream systems such as Ubuntu, Debian, Red Hat, Alibaba Cloud Linux, and Tencent Cloud, as well as common components like Docker, Kubernetes, NGINX, MySQL, and PostgreSQL. They turn "hardening" from an experience-driven activity into a checklist that can be compared, audited, and repeated.
What a CIS baseline is and how to choose
The core of a CIS baseline is a "configuration baseline", usually split into two tiers:
- Level 1: recommended settings with a clear security impact and little effect on business; enable them by default.
- Level 2: stronger security that may affect availability or performance; suitable for high-security and compliance scenarios.
Selection is based on: the operating system and distribution version (for example Ubuntu 22.04/24.04, RHEL 9) and the deployment form (physical, cloud instance, or container). Major cloud vendors typically offer baselines tailored to their platforms.
Common baseline items
A Linux server baseline typically covers:
- Accounts and permissions: remove or lock unnecessary accounts, prohibit empty passwords, and enforce password policy and account lockout.
- File system permissions: tighten permissions on sensitive files and directories and restrict SUID/SGID bits.
- SSH configuration: disable root login and enable key authentication (see SSH Hardening).
- Kernel and network: disable unnecessary services, harden
sysctlnetwork parameters, and deploy a Firewall with a default-deny policy. - Auditing and logging: enable auditd and system logging, integrated with Security Log Auditing.
Implementation steps
- Select a baseline version: download the CIS Benchmark matching your system (requires registration).
- Scan and assess: use CIS-CAT Pro or an open-source alternative to measure the current gap.
- Remediate: fix items in Level 1 then Level 2 order, validating major changes on a test machine first.
- Verify: rescan to confirm compliance rates and generate a report.
- Sustain: bake the baseline into initialization scripts with Ansible/Shell and include it in the new-server onboarding flow (see the Server Initialization Security Script).
CIS also offers CIS Hardened Images (pre-hardened images) and Build Kits that can significantly reduce manual configuration effort.
Concrete configuration snippets
On Ubuntu 22.04, several high-frequency baseline items map to concrete files. SSH hardening (SSH configuration baseline):
# /etc/ssh/sshd_config.d/hardening.conf
PermitRootLogin no
PasswordAuthentication no
MaxAuthTries 3
AllowUsers deploy
sysctl network hardening (kernel and network baseline):
# /etc/sysctl.d/99-hardening.conf
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.accept_source_route = 0
net.ipv6.conf.all.accept_source_route = 0
net.ipv4.ip_forward = 0
Password policy (accounts and permissions baseline, PAM):
# /etc/pam.d/common-password — append
password requisite pam_pwquality.so retry=3 minlen=12 dcredit=-1 ucredit=-1
Audit rules (auditing and logging baseline):
# /etc/audit/rules.d/hardening.rules
-w /etc/passwd -p wa -k identity
-w /etc/ssh/sshd_config -p wa -k sshd_config
-a always,exit -F arch=b64 -S execve -k exec_events
Apply with sysctl --system and systemctl restart sshd auditd, then rescan. When changing items one by one, back up the original file and validate on a test machine first so you never break a production box.
Why common baseline items are hardened that way
A few high-frequency items show the logic behind the baseline:
- Password policy and lockout: minimum length, maximum age, and failure lockout reduce weak-password and brute-force risk; pair it with two-factor authentication for stronger results.
- SUID/SGID management: audit and remove unneeded privilege bits to shrink local privilege-escalation paths.
- sysctl network parameters: disable IP forwarding (outside gateways) and source routing, and enable reverse-path filtering to shrink the network attack surface.
- Service minimization: remove or disable unused services and packages to reduce potential vulnerability entry points.
- auditd auditing: record key file and login events to provide an evidence chain for incident response.
A real hardening walkthrough
Say you just received a fresh Ubuntu 22.04 cloud instance and the target is Level 1. The process looks like this: run a CIS-CAT Pro Assessor scan to get a gap report (often a PDF running to tens of thousands of lines); remediate item by item — first low-impact changes like file permissions and audit rules, then anything with side effects, such as disabling password login only after confirming keys are in place; rescan and push compliance from an initial 60%-70% to above 95%; finally bake the fixes into an Ansible playbook as the default action for new-server onboarding. Once the flow is familiar, taking a bare machine from zero to baseline takes roughly half a day — far faster than manual item-by-item triage.
Reference scan command (CIS-CAT Pro):
java -jar CIS-CAT.jar assess -i -b profiles/Ubuntu_Linux_22.04-LTS-Benchmark-v2.0.0.xml -p Level_1
Higher compliance is not always better — some Level 2 items trade away availability. First decide whether the goal is a hard regulatory/audit requirement or an internal security bar, then pick the target level.
Baseline maintenance and version upgrades
A baseline is not a one-time action: re-assess after major OS upgrades, new software rollouts, and whenever CIS releases a new benchmark revision. Run a baseline inspection at least quarterly, and write "new servers must pass the baseline" into the onboarding flow so the security bar does not decay as the server fleet grows.
- No dedicated security staff — where should I start:Start with the Level 1 baseline for your system and cover the high-frequency items first: SSH, passwords, and auditing.
- Is CIS-CAT Pro mandatory/paid:For personal assessment, use the community edition or open-source alternatives like Lynis for initial checks; use the commercial edition for formal compliance audits.
- Are cloud vendor images already secure:Most are only minimally configured — you still need to verify each baseline item.
- How often should I rescan:After every version upgrade and major software change, and at least quarterly.
16IDC Observation
For sites without a dedicated security team, the biggest value of a CIS baseline is turning "I do not know where to start" into "tick items off a checklist". Make it the default action for server onboarding and periodic inspection, and combine it with Vulnerability Scanning for a "configuration baseline plus continuous vulnerability management" double safeguard. Browse more options back in the Security Hardening category.
References: CIS Benchmarks official https://www.cisecurity.org/cis-benchmarks; CIS-CAT Pro Assessor https://www.cisecurity.org/cybersecurity-tools/cis-cat-pro/cis-cat-pro-assessor; CIS Workbench (registration required to download benchmarks) https://workbench.cisecurity.org/
Configuration & Integration Examples
Example 1: A read-only self-check for key baseline items
#!/usr/bin/env bash
# cis_selfcheck.sh -- read-only checks, no system changes
set -uo pipefail
rc=0
chk() { # chk <description> <command>
if eval "$2"; then echo "PASS $1"; else echo "FAIL $1"; rc=1; fi
}
chk "root SSH login disabled" "sshd -T | grep -qi '^permitrootlogin no'"
chk "password auth disabled" "sshd -T | grep -qi '^passwordauthentication no'"
chk "reverse path filtering on" "sysctl -n net.ipv4.conf.all.rp_filter | grep -qx 1"
chk "IP forwarding disabled" "sysctl -n net.ipv4.ip_forward | grep -qx 0"
chk "auditd is running" "systemctl is-active --quiet auditd"
exit "$rc"
sshd -T prints the merged, effective configuration, which is more reliable than grepping the config file. The script changes nothing and returns non-zero when any item fails, so it drops straight into a cron job or pipeline.
Example 2: Deploy and verify audit rules
#!/usr/bin/env bash
# Idempotently install CIS audit rules
set -euo pipefail
RULES=/etc/audit/rules.d/10-cis.rules
cat > "$RULES" <<'EOF'
-w /etc/passwd -p wa -k identity
-w /etc/group -p wa -k identity
-w /etc/ssh/sshd_config -p wa -k sshd_config
-a always,exit -F arch=b64 -S execve -F auid>=1000 -F auid!=-1 -k exec
EOF
augenrules --load
systemctl restart auditd
auditctl -l | wc -l
ausearch -k identity -i -ts recent | head -n 5
Rules must live under /etc/audit/rules.d/ to survive reboots. After augenrules --load, auditctl -l confirms how many rules are active and ausearch -k identity replays changes to account files.
Read-Only Checks and How Each Baseline Item Takes Effect
Changing a baseline item is not the same as getting it right. Each class of setting has a read-only command that shows what is in effect without touching the system, which beats grepping config files one by one.
The table pairs each item with its configuration file, its read-only check and how it takes effect. Commands come from the self-check script and configuration examples above; expected values come from the same script's conditions.
| Baseline item | Configuration file | Read-only check (command and expectation) | How it takes effect |
|---|---|---|---|
| Root SSH login disabled | /etc/ssh/sshd_config.d/hardening.conf |
sshd -T shows permitrootlogin no |
systemctl restart sshd |
| Password auth disabled | same | sshd -T shows passwordauthentication no |
systemctl restart sshd |
| Reverse path filtering | /etc/sysctl.d/99-hardening.conf |
sysctl -n net.ipv4.conf.all.rp_filter returns 1 |
sysctl --system |
| IP forwarding disabled | same | sysctl -n net.ipv4.ip_forward returns 0 |
sysctl --system |
| Audit service running | /etc/audit/rules.d/ and the auditd service |
systemctl is-active --quiet auditd exits 0 |
augenrules --load, then restart auditd |
sshd -T prints the merged effective configuration, which is more reliable than grepping a file: a drop-in directory can hold several files and the one that wins may not be the one you edited. That is why the self-check script uses it.
The sysctl and audit items each have an easy-to-miss step. Run sysctl --system after kernel changes; audit rules must sit under /etc/audit/rules.d/ before augenrules --load so they survive a reboot — writing them and stopping there is a common outcome.
The script changes nothing and returns non-zero when any item fails, so it drops into a cron job or pipeline. It does not replace a full CIS-CAT scan, but it answers "pass or fail" the moment a change lands.
Limitations
- Rules must live under
/etc/audit/rules.d/to survive reboots. - This article reflects public information as of 2026-08-06; terms, prices and quotas follow the provider's current published terms.
- Third-party capability and limit statements follow their official documentation; no further commitment is implied here.
- Licensing, filing and data-residency decisions must be verified against the regulations of your operating region.
FAQ
What prerequisites does a CIS baseline run need?
Get the benchmark that matches your release, such as v2.0.0 for Ubuntu 22.04, and a test machine of the same version. Scan with CIS-CAT Pro or Lynis, and back up sshd_config, sysctl settings and audit rules before editing. Without a test box, run a read-only check first.
A hardened item does not take effect — how do you debug it?
You should read merged state with sshd -T instead of grepping config files. Run sysctl --system after kernel changes, and keep audit rules under /etc/audit/rules.d/ before augenrules --load so they survive reboot; confirm the count with auditctl -l, check that no file under /etc/ssh/sshd_config.d/ overrides the edit, then rescan Level 1.
How should you manage SSH keys before disabling passwords?
You should prove key auth works first: push the public key, log in with -i and the private key, and only then set PasswordAuthentication to no. Otherwise a dropped session locks you out and you fall back to console rescue, so keep at least 1 logged-in session open for verification.
Should Lynis run instead of CIS-CAT Pro for audits?
Use Lynis for the first gap scan because it is free; formal compliance audits use CIS-CAT Pro Assessor because the report maps to items. Daily checks need only read-only scripts with sshd -T and sysctl -n rather than a full scan. What you pay for is report structure and coverage, not speed.
Related Providers
- Qualys: when CIS checks must become recurring compliance reports that leave evidence for audits.
- Nessus: when an existing vulnerability workflow should carry configuration-baseline checks in the same result set.
- Rapid7: when assets span several clouds and on-prem racks and baselines are pushed per asset group.
Community & Resources
Official docs and communities
- CIS Benchmarks — the official entry point for OS and component baselines
- CIS Red Hat Linux Benchmark — a sample baseline with Level 1 and Level 2 items
- NIST Cybersecurity Framework — how configuration baselines fit overall security governance
- Stack Overflow: linux — real-world SSH, permission, and kernel parameter issues
Learning resources and tools
- Lynis — open-source host audit tool for a first gap scan
- audit-userspace — upstream repository for auditd and auditctl
- OpenSCAP — automated SCAP-based compliance scanning
- firewalld — firewall management with a default deny inbound policy
Original source: Center for Internet Security (CIS) ↗