Lynis said 65. Then the reboot said 69.
I ran a hardening pass on a lab VM and watched the score go 65 → 70 → 69 → 72 → 74.
The interesting number is the 69. That is the one where the score went down after I fixed things, and it is the only part of the sequence I would trust in a report.
The starting point
The VM was not fresh. Six earlier fixes were already applied: root login off, X11 forwarding off, an AllowUsers line, MaxAuthTries 3. Baseline:
Hardening index : 65 [############# ] Tests performed : 256 Suggestions : 43 Warnings : 0
Zero warnings and forty-three suggestions says one thing precisely: none of Lynis's high-severity tests failed. It is not a clean bill of health — warnings are the tool's own severity classification, and a check that could not run returns “skipped”, not “warning”. I treat the absence of warnings as “nothing the scanner rates as urgent”, not as “nothing is wrong”.
First fix: SSH, seven settings, one refusal
Seven of the suggestions pointed at sshd. I did not copy them.
LogLevel VERBOSE # logs the key fingerprint at login MaxSessions 2 # max 2 sessions per TCP connection, not 10 AllowTcpForwarding no # the box stops being a tunnel AllowAgentForwarding no # your agent cannot be hijacked here ClientAliveInterval 300 # without this, TCPKeepAlive no ClientAliveCountMax 2 # leaves dead sessions hanging TCPKeepAlive no
The last two are a pair. Lynis suggests both, but applied on their own — with the shipped default ClientAliveInterval 0 — they disable the only mechanism that notices a dead peer: sshd_config(5) says it plainly, “if TCP keepalives are not sent, sessions may hang indefinitely”. Setting the interval first, then turning TCP keepalive off, keeps the detection without the TCP-level probing. A checklist is not a plan.
The one I refused: move SSH off port 22. It does not reduce the risk of someone who is actually targeting you — a port scan finds the service in seconds. What it does buy is a quieter log and less background noise from automated scanners; what it costs is that the same noise disappears from your own logs too. That is a policy trade-off, not a hardening result, so the report states it as a decision instead of quietly skipping it.
65 → 70
Then the reboot
Twenty-three pending updates, a kernel bump, one reboot. The score came back 69.
One new suggestion had appeared:
FIRE-4590 Configure a firewall/packet filter firewall_active=0 firewall_installed=0 firewall_empty_ruleset=1
Before the reboot Lynis listed a firewall among the detected components; after it, the check that runs the packet filter reported none. I can show the observation, not the cause: my own evidence pack, taken before the reboot, already recorded nftables as disabled with an empty ruleset. So the most likely reading is that Lynis changed its mind once it looked at the live filter instead of at installed software — and that nothing was ever persisted, which is the part I can demonstrate. “The rules were in memory” is a plausible explanation, not a measured one, and I am not going to dress it up as one.
A score that goes down after a reboot is more useful than one that only goes up. It means the tool noticed. The dangerous version of this exercise is the one where you fix ten things, never reboot, and ship a report describing a machine that will not exist tomorrow morning.
The evidence that is not a score
I applied a default-deny ruleset with nftables, with a timed undo armed first. One correction to how this is usually written down: flushing the ruleset is not a rollback. It does not restore the previous state — it drops you to “no ruleset at all”, which is a different configuration. The honest version saves the previous state and restores exactly that:
nft list ruleset > /root/nft-before.nft # 1. save what is live now nft -c -f /etc/nftables.conf # 2. syntax check, free systemd-run --on-active=180 --unit=nft-undo \ /bin/sh -c 'nft -f /root/nft-before.nft' # 3. timed restore, not flush systemctl enable --now nftables # 4. apply # 5. open a NEW ssh session — not the one you already have systemctl stop nft-undo.timer # 6. only if step 5 works
Limits of even that: the restore file is a snapshot of the live ruleset, not of the service state — if the host had no nftables service enabled before, restoring the rules leaves you with rules that vanish at the next reboot. Save that too (systemctl is-enabled nftables) and put it back. And if the box is unreachable, none of this helps: you need console access, and that is worth knowing before the window, not during it.
Here is the part I would put in front of a client, because it needs no trust in any scanner:
from another host, against that machine: port 22 → open (8 ms) port 8080 → timeout after 5 s ← DROP, not REFUSE port 3306 → timeout after 5 s ← DROP, not REFUSE
A closed port on a host without a firewall answers instantly with a TCP reset: “connection refused.” Here it goes silent — consistent with policy drop. It is not proof on its own: a timeout also happens when a host is down, a route is blackholed, or something upstream swallows the packet. What makes it evidence is the pair of observations — refused before, silent after, with the drop rule visible on the host. That is why the pack keeps both sides instead of one screenshot.
Where scores plateau, and why
Then the last round: banner, login.defs (umask, password age), four unused kernel protocols blacklisted, fail2ban. Suggestions dropped 43 → 26. The score moved 72 → 74.
Most of that work removed suggestions without moving the number much, because the index is:
hardening_index = points × 100 / total_points
Useful up to a point: it is a weighted checklist normalised to 100, comparable over time on one host. It is not a risk score, and comparing two different machines by index is meaningless — they are not even measured against the same tests.
Every test has a fixed maximum, and tests are not weighted equally. Fixing twelve low-weight items earns less than one heavy one. So the last few points are not more work — they are different work: auditd, file integrity monitoring, remote logging. Those are the things I would price separately instead of bundling into a cheap audit and doing badly.
Two traps worth stealing
1. sudo tee file <<'EOF' sudo reads its password from stdin. Your heredoc is stdin. The first line of your config becomes a password attempt, tee writes nothing, and the error goes to stderr you scroll past. Fix: sudo -v first, then the heredoc. 2. systemctl restart fail2ban && fail2ban-client status sshd Too fast. The client asks for a socket the server has not created yet. “Failed to access socket” is a race, not a broken service.
What I refused, and why that is the product
Eight suggestions stayed refused on purpose:
Port 22 theatre, not risk GRUB password lockout risk at boot, for little gain /home /var separate a reinstall, not an audit finding SHA_CRYPT rounds outdated: this system uses YESCRYPT USB storage off irrelevant on a VM, a policy call on a laptop malware scanner poor cost/benefit on a server, offer it separately auditd, AIDE the next level, priced separately remote logging needs a second host to mean anything
Anyone can run a scanner and paste its output. What a client is paying for is the paragraph next to each finding that says do this, skip that, and here is the reason. The refusals are where the judgement shows — and they are also where a report stops being copy-pasteable from a blog post.
The takeaway
If you are going to run a hardening benchmark, run it three times: before, after, and after a reboot. The third run is the only one describing the machine you will actually have. And keep the raw output of all three — not because the score matters, but because the diff is the only claim you can defend six months later when someone asks what changed.
Sources: sshd_config(5) for ClientAliveInterval, TCPKeepAlive, MaxSessions; Lynis at cisofy.com/lynis (the index formula is in include/report); nftables wiki for flush ruleset semantics.
Want your server checked? I run a read-only Server Health Check — what's actually enforced, what's only written in a file, and a before/after you can keep. No access to your data required.