Notes
Baselines
The core idea is a baseline: a documented, known-good configuration that every server should match. A default install has services on that you will never use, loose settings and extra packages, each one more attack surface. A baseline says exactly how a hardened host should look, so you can measure any machine against it. When a host drifts away from the baseline, you catch and fix it. Consistency itself is a security property, because surprises are where attackers live.
- default = many services on, loose settings, extra packages
- a baseline is a documented secure config for your OS
- measure every host against it
- drift = a host that no longer matches; catch and fix it
- consistency is a security property
CIS Benchmarks
You do not write a baseline from scratch. The Center for Internet Security publishes the CIS Benchmarks: detailed, free checklists for almost every operating system and major application, from Ubuntu and Red Hat to Docker, Kubernetes, the clouds and databases. Each benchmark has two levels, a practical level one and a stricter level two, and each item explains what to set, why it matters, how to apply it and how to check it. It is the standard starting point for hardening.
- published by the Center for Internet Security
- per-OS and per-app checklists (Ubuntu, RHEL, Docker, K8s, cloud, databases)
- two levels: L1 practical, L2 stricter
- each item: what, why, how to fix, how to audit
Scan it
To find your gaps, scan. Lynis is a free, quick tool: run it and it gives a hardening index score and a list of warnings and suggestions, grouped by area. OpenSCAP is more formal, evaluating a machine against official SCAP content, including CIS and government profiles, and producing a pass-or-fail report per rule. Run one on a fresh server to see the starting point, then after each change to watch the score climb. Measuring beats guessing.
Lynis (free, quick): lynis audit system → hardening index + warnings OpenSCAP (SCAP content): oscap xccdf eval --profile cis ... → pass/fail report run on a fresh box to see the starting point
High-value steps
Not every benchmark item matters equally, so start where the risk is. Remove packages and services you do not use, and close the ports they opened. Harden SSH, as the last episode showed. Tighten sudoers and SUID for least privilege. Turn on the firewall and auditd. Enable automatic security patching. Set a sensible login and password policy and lock unused accounts. Disable ancient protocols and set secure mount options like nosuid on scratch space. These few areas remove most of the practical risk.
- remove unused packages and services; close unused ports
- SSH hardening (last episode)
- least privilege: sudoers, SUID
- enable the firewall + auditd
- patch automatically
- password/login policy, lock unused accounts
- disable old protocols, set secure mount options
At scale
Hardening one server by hand is easy and does not last. Across a fleet you apply the baseline as code: an Ansible role, or ready-made hardening content, that enforces every setting the same way everywhere. Better still, bake the baseline into a golden image with a tool like Packer, so every new server starts already hardened rather than being fixed afterwards. In the cloud that means hardened base images. Now the baseline is version-controlled and reviewed, which Part nine covers.
- Ansible roles, or the CIS- provided hardening content
- bake it into a golden image (Packer) so new servers start hardened
- cloud: hardened base AMIs
- infra as code so the baseline is version-controlled and reviewed (Part 9)
Keep it applied
Hardening is not a one-time event; it decays as people make changes and emergencies get patched by hand. So verify continuously. Re-scan on a schedule and alert when the score drops or a specific control fails. Let configuration management re-apply the baseline on every run, so unauthorised changes are reverted automatically. And treat significant drift as something to investigate, because a control that someone quietly turned off might be an attacker clearing the way, not just a tired engineer.
- re-scan on a schedule, not once
- alert when the hardening score drops or a control fails
- config management re-applies the baseline every run
- treat drift as an incident to investigate: who changed it, and why
A caution
One caution: harden with judgement. Some benchmark items, especially level two, can break real applications, so test changes in staging before production. When you cannot apply an item, document the exception with a reason and an owner rather than silently skipping it. The goal is a system that is both secure and operable; a server so locked down that the app fails is not a win. Use the benchmark as a strong starting point, and decide each item on its merits.
- L2 and some L1 items can break apps: test in staging first
- document exceptions with a reason and an owner
- balance security with operability
- a benchmark is a starting point, not a law
- measure the score, but use judgement on each item
Common mistakes
Mistakes. Hardening by hand, once, so it is inconsistent and decays. Having no baseline, so every host is a little different and none can be reasoned about. Applying strict items blindly and breaking applications, which teaches people to distrust hardening. Ignoring drift. Chasing a high scan score while never actually patching. Having no process for documented exceptions. And, most common, leaving new servers to be hardened later, which usually means never.
- hardening by hand, once
- no baseline, every host unique
- applying L2 blindly, breaking apps
- ignoring drift
- a great score, no patching
- no exceptions process
- new servers start unhardened
Say it like this
In the interview: I harden Linux against a CIS Benchmark as the baseline, scanning with Lynis or OpenSCAP to get a hardening score and the specific gaps. I apply the baseline as code with Ansible and bake it into golden images with Packer, so every new server starts hardened rather than being fixed later. Then I re-scan on a schedule and alert on drift, testing stricter items in staging first and documenting any exceptions with an owner.
- "Against a CIS Benchmark as the baseline, scanned with Lynis or OpenSCAP for a score and gaps.
- I apply it as code with Ansible
- and bake hardened golden images, so new servers start secure.
- Then I re-scan on a schedule and alert on drift, testing strict
- items in staging first."