Lynis

Lynis: Linux audit and hardening

March 6th, 2022

Strong security begins with strong foundations.

That is the reason why CISOfy have created Lynis. An automated tool that will perform a Linux healthcheck on your server / computer.

What is Lynis?

Lynis is a Free and Open Source Software (FOSS). There is also a paying version of Lynis named Lynis Enterprise. It exists as SaaS or Self-Hotsed. I am only going to focus on the Lynis FOSS version here.

Lynis will scan, assess and report you the following:

For each category, Lynis will provide one of the following status:

All this for the incredible price of:

ZERO!

Install Lynis

Deploying Lynis is a bit tricky...or not.

					
$ 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.
					

Audit your system with Lynis

Here again it's very complicated.

					
sudo lynis audit system
					

Wait 1 min for it to run.

Enjoy your first raw report

Raw report

Raw report

Fixing your findings with Lynis

First look at the details with following command and Lynis ID:

					
sudo lynis show details PKGS-7346
					

PKGS-7346

You will even find an online help for the findings: https://cisofy.com/lyrics/controls/PKGS-7346

PKGS-7346-web

More friendly report

Lynis is great but when it comes to report and sharing it with your colleagues or simply for analysis convenience the shell report might not be the best option for a long term usage.

I have found two easy ways to improve user friendliness of these reports.

Method 1: Output shell report into HTML file

Very cheap and easy way using ansi2html

					
sudo apt install colorized-logs					
sudo lynis audit system | ansi2html -l > report.html
					

Use your favorite browser to review the audit report.

Method 2: Lynis report converter

This great piece of code on github will give you possibility to convert your lynis report into HTML, PDF, Excel, JSON and XML!

https://github.com/d4t4king/lynis-report-converter

The whole installation and usage is explain on the github readme page.

Here is a picture of the HTML produced:

HTML lynis report

As Lynis comes with a plug-in integration, check on internet for plug-in or develop your own.

Conclusion

Lynis is a powerful free software that can help you create a customized hardened image that can be used after as a template to deploy on your whole environment. This give you the possibility to begin a new path of having what you want blocked from the beginning and based on the differents IT projects needs relax what needs to be relaxed. A whitelisting approach is always more powerful because it demonstrate a higher level of manturity and deeper knowledgee of your environments.

I hope that you will give Lynis a try because it's only 10 min work to try. Give it a chance!