Linux Hardening
Cheat sheet · https://pcornel.dk/topic.php?topic=2853
Answer
Linux hardening applies a baseline: minimal packages and services, automatic security updates, strong authentication, SSH hardening, firewall, MAC enforcing, secure mount options, kernel sysctl settings, auditing and logging. Benchmarks such as CIS describe it.
Remember
Automate the baseline (Ansible, OpenSCAP) rather than hand-editing. Scan with OpenSCAP (oscap) or Lynis and fix findings by priority. Test services after each hardening change.
First checks
sestatus / aa-status— SELinux or AppArmor statess -tulpn— listening servicesjournalctl -u sshd -g 'Failed'— failed loginsausearch -m avc,user_login -ts today— audit events (auditd)
Commands
ss -ltnupnft list rulesetsudojournalctl -u myappsystemctl list-unit-files --state=enabled
Verify in this order
baseline defined → applied by automation → scanned → findings fixed → re-scanned
Where it usually breaks
First mismatch in identity/group resolution → Unix mode/ACL/capability → mount/sandbox constraint → SELinux/AppArmor policy → credential/TLS trust → protected operation; preserve identity/native diagnostic/pre-state before mutation.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2853