How to Set Up Security Auditing with Lynis

Lynis is a comprehensive, open-source security auditing tool that scans your system and provides specific, actionable hardening recommendations — an excellent way to get a broad security health check.

What Lynis Checks

Hundreds of individual security-relevant items — system configuration, installed software versions, firewall rules, SSH configuration, file permissions, and much more — producing a scored report with specific recommendations.

Step 1 — Install Lynis

sudo apt install lynis -y

Step 2 — Run a Full System Audit

sudo lynis audit system

Step 3 — Review the Hardening Index Score

Lynis provides an overall hardening index (a rough score out of 100) — useful as a general indicator, though the specific individual findings matter more than chasing a perfect score in isolation.

Step 4 — Review Individual Warnings and Suggestions

The report categorizes findings into warnings (more significant issues) and suggestions (improvements worth considering) — each includes a specific test ID you can look up for more detailed remediation guidance.

Step 5 — Address Findings Systematically

Don't try to fix everything at once — prioritize based on actual risk relevant to your specific server's role and exposure; not every generic suggestion applies equally to every server's specific context.

Example Common Findings and Fixes

Common FindingTypical Fix
SSH root login not disabledSee SSH Hardening: Change the Port, Disable Root Login & Use SSH Keys
No automatic security updates configuredSee How to Enable Automatic Security Updates on Ubuntu & Debian
Weak file permissions on sensitive filesSee How to Audit and Fix File and Directory Permissions on a Linux VPS
No firewall configured or overly permissive rulesSee How to Configure UFW Firewall on a Linux VPS

Reviewing the Detailed Log File

sudo cat /var/log/lynis.log

Contains more detailed technical output than the summary report, useful for deeper investigation of specific findings.

Running Lynis Regularly

sudo crontab -e
0 4 1 * * /usr/bin/lynis audit system --cronjob >> /var/log/lynis-monthly.log 2>&1

Monthly audits catch configuration drift or newly-relevant recommendations as Lynis itself is updated with new checks over time.

Comparing Reports Over Time

Save reports with timestamps and compare periodically — a declining hardening index or new warnings can indicate configuration drift or newly-introduced issues worth investigating.

Lynis as One Tool Among Several

Lynis provides excellent broad coverage but isn't a complete security solution alone — combine with the specific, deeper practices covered throughout this Security & Hardening category (Fail2Ban, file integrity monitoring, proper firewall configuration) for genuinely comprehensive coverage.

Common Errors

Overwhelmed by the number of findings — a fresh, unhardened system can generate many findings; work through them systematically over time rather than expecting to resolve everything in one session.

Continue Reading

Browse more articles in Server Security & Hardening.

  • lynis security audit, linux security scanner, lynis hardening index, server security audit tool
  • 0 Utilizadores acharam útil
Esta resposta foi útil?

Artigos Relacionados

SSH Hardening: Change the Port, Disable Root Login & Use SSH Keys (Ubuntu & Debian)

SSH is the front door to your VPS — and by default it listens on a well-known port, often...

How to Install and Configure Fail2Ban on Ubuntu & Debian (Complete Guide)

Fail2Ban monitors your server's log files and automatically blocks (bans) IP addresses that show...

How to Configure UFW Firewall on a Linux VPS (Ubuntu & Debian)

UFW (Uncomplicated Firewall) is the standard firewall front-end on Ubuntu and Debian. A correctly...

How to Enable Two-Factor Authentication (2FA) for SSH on a Linux VPS

Two-Factor Authentication (2FA) adds a second layer of protection to SSH: even if your password...

VPS Security Checklist for Beginners: 12 Essential Steps

Every new VPS is deployed with default settings that are convenient but not secure. This...