Why
From https://cisofy.com/lynis/:Lynis is a battle-tested security tool for systems running Linux, macOS, or Unix-based operating system. It performs an extensive health scan of your systems to support system hardening and compliance testing.Lynis provides an automated, comprehensive security audit that helps identify vulnerabilities, misconfigurations, and areas for improvement in your server’s security posture.
Goals
- Lynis installed and ready to perform security audits
- Regular security scans to identify and address vulnerabilities
Notes
- CISOFY provides packages for many distributions
- Check https://packages.cisofy.com/ for distribution-specific installation instructions
- Lynis is actively maintained and regularly updated
References
- https://cisofy.com/documentation/lynis/get-started/
- https://packages.cisofy.com/community/#debian-ubuntu
- https://thelinuxcode.com/audit-lynis-ubuntu-server/
- https://www.vultr.com/docs/install-lynis-on-debian-8
Installation and Setup
Running a Security Audit
To perform a comprehensive security audit of your system:- Scan your entire system
- Check for security issues and vulnerabilities
- Report findings with severity ratings
- Provide suggestions for improvement
The audit is read-only and does not make any changes to your system. It’s safe to run at any time.
Understanding the Output
Lynis provides detailed output organized into sections:Status Indicators
- [OK] - Check passed, no issues found
- [WARNING] - Potential issue that should be reviewed
- [SUGGESTION] - Recommendation for improvement
- [FOUND] - Item was detected
- [NOT FOUND] - Item was not detected
Sections Audited
Lynis checks numerous areas including:- System tools and commands
- Boot and services
- Kernel configuration
- File system integrity
- Users and authentication
- File permissions
- SSH configuration
- Network configuration
- Firewall settings
- Software packages
- Logging and auditing
Hardening Index
At the end of the scan, Lynis provides a hardening index score (0-100) indicating your system’s overall security posture.Reviewing Results
Review warnings
Pay special attention to items marked as WARNING. These often indicate security issues that should be addressed.
Review suggestions
Examine the SUGGESTION items. These are recommendations that can improve your security posture.
Common Findings and Actions
After running Lynis, you’ll likely see suggestions such as:- Install additional security tools (like fail2ban, rkhunter)
- Harden SSH configuration (disable root login, change port)
- Configure a firewall (UFW, iptables)
- Enable automatic security updates
- Set up file integrity monitoring (AIDE)
- Configure audit logging (auditd)
- Review user accounts and permissions
Additional Lynis Commands
Automated Audits
You can set up Lynis to run automatically:Customizing Scans
Create a custom profile in/etc/lynis/custom.prf:
Next Steps
After running Lynis:- Document the findings - Keep a record of your security audit results
- Prioritize issues - Address critical warnings first
- Implement suggestions - Work through recommendations systematically
- Re-run audits - After making changes, run Lynis again to verify improvements
- Schedule regular audits - Make security audits part of your routine maintenance