Linux server hardening
Hardening a Debian server against the CIS Benchmark, with before-and-after audits using Lynis.
Study lab in an isolated, authorized environment using my own or intentionally vulnerable systems. No third-party systems were tested.
Problem
Default installs leave services, permissions and settings more open than necessary, widening the attack surface.
Technical goal
Shrink the attack surface of a Linux server and produce a reusable checklist.
How it was done
Generate a Lynis baseline and record the findings.
Harden SSH: keys only, no root login, modern algorithms.
Apply an nftables firewall with a default-deny policy.
Enable auditd and keep logs of authentication and sensitive changes.
Remove unneeded services and enable automatic security updates.
Run a new audit and compare with the baseline.
Evidence
PermitRootLogin noPasswordAuthentication noKbdInteractiveAuthentication noPubkeyAuthentication yesMaxAuthTries 3LoginGraceTime 30X11Forwarding noAllowTcpForwarding noKexAlgorithms sntrup761x25519-sha512@openssh.com,curve25519-sha256Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.comtable inet filter { chain input { type filter hook input priority 0; policy drop; ct state established,related accept iif lo accept tcp dport 22 ct state new limit rate 10/minute accept icmp type echo-request limit rate 5/second accept }}Key takeaways
- Measure before changing: without a baseline there's no way to show improvement.
- Hardening is a balance; every control has to fit how the server is actually run.
- A versioned checklist is worth more than a perfect server nobody can reproduce.