The Center for Internet Security (CIS) Benchmarks are the gold standard for system hardening. In this lab you will understand the CIS Level 1 vs Level 2 distinction, run an automated Lynis audit to score your baseline, and then apply the most impactful CIS controls: mount options, core dump restrictions, SSH hardening, password policies, sudo configuration, warning banners, and cron access control.
Step 1 — Understand CIS Benchmark Structure
CIS publishes profiles at two levels:
Level
Purpose
Impact
Level 1
Base hardening; minimal operational impact
Low risk, broad applicability
Level 2
Deep hardening for high-security environments
May break some services
💡 Tip: For most production servers start with Level 1 and selectively apply Level 2 controls after testing.
# Install Lynis — the de-facto CIS scoring tool for Linuxapt-getupdate-qq&&apt-getinstall-ylynis# Check versionlynis--version
Apply all controls from Steps 3–7 in one script, then re-run Lynis to measure improvement.
📸 Verified Output:
💡 Tip: In a real production system, additional Level 2 controls (AppArmor mandatory enforcement, USBguard, AIDE) push scores to 85+. See Lab 20 for the full capstone.
# Full quick audit (non-interactive, no colour)
lynis audit system --quick --no-colors --skip-plugins 2>&1 | tee /tmp/lynis-baseline.txt
# Extract the score and top warnings
grep -E "(Hardening index|Tests performed|WARNING|SUGGESTION)" /tmp/lynis-baseline.txt | head -30
# CIS 1.7 — Warning banners
cat > /etc/issue << 'EOF'
##########################################################################
# AUTHORISED ACCESS ONLY — All activity is monitored and logged. #
# Unauthorised access is prohibited and will be prosecuted. #
##########################################################################
EOF
cat > /etc/issue.net << 'EOF'
##########################################################################
# AUTHORISED ACCESS ONLY — All activity is monitored and logged. #
# Unauthorised access is prohibited and will be prosecuted. #
##########################################################################
EOF
# Remove OS information from motd (information disclosure)
chmod 644 /etc/motd 2>/dev/null || true
# CIS 5.1.8 — Restrict cron access
# Only root should be able to use cron
echo "root" > /etc/cron.allow
chmod 600 /etc/cron.allow /etc/cron.d /etc/cron.daily /etc/cron.weekly /etc/cron.monthly 2>/dev/null || true
# CIS 5.1.9 — Restrict at access
echo "root" > /etc/at.allow
chmod 600 /etc/at.allow 2>/dev/null || true
cat /etc/issue
##########################################################################
# AUTHORISED ACCESS ONLY — All activity is monitored and logged. #
# Unauthorised access is prohibited and will be prosecuted. #
##########################################################################