#Why this matters
Checking SSH settings, kernel parameters, sudoers, scheduled tasks, and file permissions by hand works on one host, but breaks down across a server fleet. Under deadline pressure, manual steps get skipped and configuration drift creeps in after package updates or emergency hotfixes.
Automated host auditing tools run repeatable, read-only checks against a security baseline and produce structured reports. The core defender skill is reading those findings critically, fixing high-risk gaps cleanly, and verifying improvements without breaking production workloads.
#How host auditing with Lynis works
Lynis is a lightweight, read-only auditing tool for Linux and Unix hosts. Running lynis audit system inspects boot settings, kernel sysctl parameters, PAM and SSH configuration, sudoers, file permissions, logging (auditd), firewalls, and installed security packages.
Each scan creates console output and two files on disk:
/var/log/lynis.log: detailed trace of every test executed and its result./var/log/lynis-report.dat: structuredkey=valueoutput holding warnings, suggestions, test IDs, and the Hardening Index (a relative score from 0 to 100).
- Run lynis audit systemInspect /var/log/lynis-report.dat | Triage warnings & suggestions | Apply drop-in patches | Re-run audit to verify
$ sudo lynis audit system --quick
[+] Kernel
- Checking default run level [ RUNLEVEL 5 ]
- Checking CPU support (NX/PAE) [ SUPPORTED ]
[+] Hardening
- Hardening index : 64 [############ ]
- Tests performed : 248
- Warnings (1):
! Reboot of system is most likely needed [KRNL-5830]
- Suggestions (14):
* Consider hardening SSH configuration [SSH-7408]
* Check PAM configuration, add password quality module [AUTH-9262]#Interpreting findings and prioritising remediation
Lynis divides findings into Warnings (broken or missing core controls) and Suggestions (recommended hardening). Avoid chasing a Hardening Index of 100 blindly; the score is a relative progress gauge, not an absolute measure of security.
Triage findings against the host's actual role:
| Finding type | Meaning | Recommended response |
|---|---|---|
| Warning | Broken or missing control | Investigate promptly and patch or document exception |
| Suggestion (relevant) | Missing hardening for server role | Apply via drop-in config and test service |
| Suggestion (irrelevant) | Control unsuitable for host role | Document exception in custom Lynis profile |
Inspect a finding before editing config by running lynis show details <TEST-ID> or filtering /var/log/lynis-report.dat:
$ sudo grep -E "^(warning|suggestion)\[\]=" /var/log/lynis-report.dat | head -n 4
warning[]=KRNL-5830|Reboot of system is most likely needed|-|
suggestion[]=SSH-7408|Consider hardening SSH configuration|OpenSSH|
suggestion[]=AUTH-9262|Check PAM configuration, add password quality module|-|High-value items often match controls from earlier lessons: disabling root/password SSH logins, tightening sysctl (kernel.kptr_restrict = 2, fs.suid_dumpable = 0), enabling auditd, and locking down cron or compiler permissions.
#Integrity and rootkit checks with chkrootkit
Alongside baseline auditing, defenders sometimes run chkrootkit to scan local binaries (ls, ps, netstat, sshd) for known rootkit signatures, hidden processes, and promiscuous interfaces:
$ sudo chkrootkit -q
Searching for suspicious files and dirs, it may take a while...Quiet mode (-q) hides clean checks so only suspicious items appear. Keep its limits in mind:
- Signature blind spots: Unknown or custom implants do not match built-in signatures.
- Live-host deception: A kernel rootkit can intercept syscalls and hide from user-space scanners.
- False positives: Legitimate tools such as
tcpdumptrigger promiscuous-mode alerts. Cross-check flagged binaries with package checksums (dpkg -Vorrpm -Va) or inspect offline images if compromise is suspected.
#Defending and common mistakes
- Use drop-in files, not vendor defaults: Put overrides in
/etc/sysctl.d/and/etc/ssh/sshd_config.d/so package upgrades keep your hardening intact. - Do not chase 100% blindly: Installing unneeded tools or disabling required services just to boost the score adds operational risk.
- Never treat a clean
chkrootkitrun as proof of innocence: Investigate suspected compromises offline rather than trusting local user-space checks. - Audit repeatedly: Compare
lynis-report.datover time to catch configuration drift early.
#Summary
- Lynis automates read-only Linux security auditing and writes structured findings to
/var/log/lynis-report.datalongside/var/log/lynis.log. - Use the Hardening Index as a relative baseline gauge, prioritising warnings and role-appropriate suggestions over a perfect score.
- Apply fixes in drop-in directories (
/etc/sysctl.d/,/etc/ssh/sshd_config.d/) and verify by re-running the audit. - chkrootkit provides a fast sanity check for known rootkits, but cannot reliably detect novel or kernel-level implants on a live host.