Lynis is a security auditing tool for UNIX derivatives like Linux, macOS, BSD, Solaris, AIX, and others. It performs an in-depth security scan. It is used by system administrators, auditors and security professionals, all over the world. Some of the features are:
Basics
- Open source
- Shell script
- No dependencies
- Easy to understand
Support
- Dynamic OS detection
- 300+ built-in tests
- Support for custom tests
- Plugin support
- Compliance checks
- Extensive software support
Reporting
- Report on screen and details in report file
- Reporting of warnings and suggestions
- Detailed logging
- Hardening index
Also Read – RapidRepoPull : Quickly Pull & Install Repos from its List
Installation via Git
Clone project
The first step is cloning the project. Before doing so, select the parent directory. Git will create a ‘lynis’ subdirectory with the full program in it.
$ cd /usr/local
$ git clone https://github.com/CISOfy/lynis
Cloning into ‘lynis’…
remote: Counting objects: 1733, done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 1733 (delta 3), reused 0 (delta 0), pack-reused 1725
Receiving objects: 100% (1733/1733), 886.18 KiB | 378.00 KiB/s, done.
Resolving deltas: 100% (1204/1204), done.
Checking connectivity… done.
$ cd lynis
That is it. Time to run your first security audit:
$ lynis audit system
Although no configuration is required, there are a few useful commands to learn.
Running Lynis
Ensure that you are in the right directory and add ‘./’ in front of the command, like:
$ ./lynis
Lynis can run without any preconfiguration. Configuration and fine-tuning is possible though and will be covered in later sections. For now we will run a basic scan:
$ lynis audit system
(use ./lynis audit system to start Lynis from the local directory if you didn’t install it as a software package)
Lynis and pauses
By default Lynis starts and pauses after the first section. With CTRL+C you can stop the program. With ENTER it will continue to the next set of tests.
If we want to run Lynis without any pauses, we could give it an additional parameter: –quick. This will enable the “quick” option, ideal for running Lynis while you do other things.
$ lynis audit system –quick
Report and Logging
Lynis performs an in-depth audit and reports its findings to the following outputs:
- Screen
- Logging
- Report
1. Screen output
Lynis scans the system and performs hundreds of tests. For most of these tests, a result will be displayed on the screen.
Possible tests results include:
- OK or Warning
- Found or Not found
- A value
2. Log file
The results are displayed on screen during the system scan. Additional details are logged in a separate file (default: /var/log/lynis.log). This information is useful for advanced testers, to see what the program did in the background, or where anomalies showed up.
Information in the log file
- Time of an action/event
- Reason(s) why a test failed or was skipped
- Output of (internal) tests
- Suggestions about configuration options or how to fix/improve things
- Threat/impact score
Remark: the log file is purged every scan. If you need debugging or logging information for previous scans, schedule log rotation or make a backup before running Lynis again.
3. Report files
During the audit process, Lynis will gather findings and other data points. This information is stored in the report file, which is by default /var/log/lynis-report.dat.
Lynis supports one report format, which can be used to gather results and display them in a custom or (more) friendly presentation. The report file can also be used to compare scan results from the past with a current scan. Lynis Enterprise has much more possibilities to display data, including extended reports in several formats.
Contents of report file:
- Remarks = #<remark>
- Section = [<section name>]
- Option/value = <option name>=<value of option>
When an option could have multiple values (like installed packages for example), brackets ([]) are added. Example: installed_package[]=Package-1.0.0