• Get In Touch
November 15, 2016

How to Install and Use Lynis on CentOS-7

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server

Lynis is an open source and widely used security auditing tool for Unix like operating systems. It will help system administrators and security professionals to run security scans in just few minutes and find vulnerabilities in your operating system.

Lynis scans the whole operating system and determines system information like OS type, installed packages, security issues, and system configuration.

Lynis supports almost all UNIX based operating systems such as Linux, macOS, OpenBSD, Solaris, AIX, FreeBSD, HP-UX, PcBSD, PCLinuxOS, NetBSD, Scientific Linux, Slackware, Ubuntu and many more. Lynis can also used to audit software such as Apache, Nginx, MySQL, Oracle, PostgreSQL etc.

In this tutorial, we will learn how to install and use Lynis on CentOS-7.

Requirements

  • A server running CentOS-7.
  • A non-root user with sudo privileges setup on your server.

Installing Lynis

You can install Lynis either from the source or repository.

To install Lynis from repository, you will need to install the EPEL repository first.
You can install the EPEL repo by running following command.

sudo yum install -y epel-release

Then, install Lynis with the following command:

sudo yum --enablerepo=epel install lynis

Output:

    Loaded plugins: fastestmirror
    epel/x86_64/metalink                                     | 5.2 kB     00:00     
    epel                                                     | 4.3 kB     00:00     
    epel/x86_64/primary_db         FAILED                                           
    http://mirror.rise.ph/fedora-epel/7/x86_64/repodata/c7a12e6bbbd439507bb53843a486e92ea43ac3cb24d7465428abfe4abdb81fb2-primary.sqlite.xz: [Errno 14] HTTP Error 404 - Not Found
    Trying other mirror.
    (truncated...)

To install Lynis from repository, download the Lynis source with the following command:

wget https://cisofy.com/files/lynis-2.4.0.tar.gz

Next, extract the downloaded file with the following command:

tar -xvf lynis-2.4.0.tar.gz

Change the directory to the Lynis folder and run it:

cd lynis-2.4.0
sudo lynis

Working with Lynis

Running lynis without any option will provide you a complete list of all available parameters as follows:

sudo lynis

Output:

    [ Lynis 2.3.2 ]

    ################################################################################
      Lynis comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
      welcome to redistribute it under the terms of the GNU General Public License.
      See the LICENSE file for details about using this software.

      2007-2016, CISOfy - https://cisofy.com/lynis/
      Enterprise support available (compliance, plugins, interface and tools)
    ################################################################################


    [+] Initializing program
    ------------------------------------


      Usage: lynis command [options]


      Command:

        audit
            audit system                  : Perform local security scan
            audit system remote     : Remote security scan
            audit dockerfile        : Analyze Dockerfile

        show
            show                          : Show all commands
            show version                  : Show Lynis version
            show help                     : Show help

        update
            update info                   : Show update details
            update release                : Update Lynis release


      Options:

        --no-log                          : Don't create a log file
        --pentest                         : Non-privileged scan (useful for pentest)
        --profile                : Scan the system with the given profile file
        --quick (-Q)                      : Quick mode, don't wait for user input

        Layout options
        --no-colors                       : Don't use colors in output
        --quiet (-q)                      : No output
        --reverse-colors                  : Optimize color display for light backgrounds

        Misc options
        --debug                           : Debug logging to screen
        --view-manpage (--man)            : View man page
        --verbose                         : Show more details on screen
        --version (-V)                    : Display version number and quit

        Enterprise options
        --plugin-dir ""             : Define path of available plugins
        --upload                          : Upload data to central node

        More options available. Run '/bin/lynis show options', or use the man page.

      No command provided. Exiting..

      (truncated...)

Now, let’s start the Lynis process, run lynis with -c parameter to begin scanning of your entire Linux system:

sudo lynis -c

Once you run above command it will scan your entire system and ask you to Press [Enter] to continue for every process it scans as follows:

    [ Lynis 2.3.2 ]

    ################################################################################
      Lynis comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
      welcome to redistribute it under the terms of the GNU General Public License.
      See the LICENSE file for details about using this software.

      2007-2016, CISOfy - https://cisofy.com/lynis/
      Enterprise support available (compliance, plugins, interface and tools)
    ################################################################################


    [+] Initializing program

    (truncated...)

Run Lynis with Custom Tests

It is not important to run all the tests. If you will need to test only Apache web server, then you can use –test parameter:

sudo lynis --tests "HTTP-6632 HTTP-6622 HTTP-6624 HTTP-6626"

Output:

    [+] Software: webserver
    ------------------------------------
      - Checking Apache (binary /usr/sbin/httpd)                  [ FOUND ]
          Info: Configuration file found (/etc/httpd/conf/httpd.conf)
          Info: No virtual hosts found
        * Loadable modules                                        [ FOUND ]
            - Found 100 loadable modules

    ================================================================================

      -[ Lynis 2.3.2 Results ]-

      Great, no warnings

      No suggestions

    ================================================================================

You can find more Tests-IDs inside /var/log/lynis.log.

For example, if you want to find out Kernel related Test-IDs, run the following command:

cat /var/log/lynis.log | grep KRNL

You should see the following list:

    2016-11-02 21:17:56 Skipped test KRNL-5622 (Determine Linux default run level)
    2016-11-02 21:17:56 Skipped test KRNL-5677 (Check CPU options and support)
    2016-11-02 21:17:56 Skipped test KRNL-5695 (Determine Linux kernel version and release number)
    2016-11-02 21:17:56 Skipped test KRNL-5723 (Determining if Linux kernel is monolithic)
    2016-11-02 21:17:56 Skipped test KRNL-5726 (Checking Linux loaded kernel modules)
    2016-11-02 21:17:56 Skipped test KRNL-5728 (Checking Linux kernel config)
    2016-11-02 21:17:56 Skipped test KRNL-5730 (Checking disk I/O kernel scheduler)
    2016-11-02 21:17:56 Skipped test KRNL-5745 (Checking FreeBSD loaded kernel modules)
    2016-11-02 21:17:56 Skipped test KRNL-5770 (Checking active kernel modules)
    2016-11-02 21:17:56 Skipped test KRNL-5788 (Checking availability new Linux kernel)
    2016-11-02 21:17:56 Skipped test KRNL-5820 (Checking core dumps configuration)
    2016-11-02 21:17:56 Skipped test KRNL-5830 (Checking if system is running on the latest installed kernel)
    2016-11-02 21:18:13 Skipped test KRNL-6000 (Check sysctl key pairs in scan profile)

Next, run lynis with the parameters below:

`sudo lynis –tests “KRNL-5622 KRNL-5677 KRNL-5695 KRNL-5723 KRNL-5726 KRNL-5728 KRNL-5730 KRNL-5745 KRNL-5770 KRNL-5788 KRNL-5720 KRNL-5730 KRNL-5830 KRNL-6000”

You should see the following output:

    [+] Kernel
    ------------------------------------
      - Checking default runlevel                                 [ runlevel 3 ]
      - Checking CPU support (NX/PAE)
        CPU support: PAE and/or NoeXecute supported               [ FOUND ]
      - Checking kernel version and release                       [ DONE ]
      - Checking kernel type                                      [ DONE ]
      - Checking loaded kernel modules                            [ DONE ]
          Found 70 active modules
      - Checking Linux kernel configuration file                  [ FOUND ]
      - Checking default I/O kernel scheduler                     [ FOUND ]
      - Check if reboot is needed                                 [ NO ]

    (truncated...)

Check and Update your Version of Lynis

If you want to see the current version of Lynis on your system run the following command:

sudo lynis update info

Output:

     == Lynis ==

      Version         : 2.3.2
      Status          : Unknown
      Release date    : 2016-08-09
      Update location : https://cisofy.com/lynis/


    2007-2016, CISOfy - https://cisofy.com/lynis/

To upgrade current lynis version, run the following command:

sudo lynis update release

That’s it..

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server

Share this Article!

Related Posts

Node.js Authentication – A Complete Guide with Passport and JWT

Node.js Authentication – A Complete Guide with Passport and JWT

Truth be told, it’s difficult for a web application that doesn’t have some kind of identification, even if you don’t see it as a security measure in and of itself. The Internet is a kind of lawless land, and even on free services like Google’s, authentication ensures that abuses will be avoided or at least […]

Node.js and MongoDB: How to Connect MongoDB With Node

Node.js and MongoDB: How to Connect MongoDB With Node

MongoDB is a document-oriented NoSQL database, which was born in 2007 in California as a service to be used within a larger project, but which soon became an independent and open-source product. It stores documents in JSON, a format based on JavaScript and simpler than XML, but still with good expressiveness. It is the dominant […]

Using MySQL with Node.js: A Complete Tutorial

Using MySQL with Node.js: A Complete Tutorial

Although data persistence is almost always a fundamental element of applications, Node.js has no native integration with databases. Everything is delegated to third-party libraries to be included manually, in addition to the standard APIs. Although MongoDB and other non-relational databases are the most common choice with Node because if you need to scale an application, […]

Node.Js Vs Django: Which Is the Best for Your Project

Node.Js Vs Django: Which Is the Best for Your Project

Django and NodeJs are two powerful technologies for web development, both have great functionality, versatile applications, and a great user interface. Both are open source and can be used for free. But which one fits your project best? NodeJs is based on JavaScript, while Django is written in Python. These are two equally popular technologies […]

Nodejs Vs PHP:  Which Works Best?

Nodejs Vs PHP: Which Works Best?

Before getting into the “battle” between Node.js and PHP we need to understand why the issue is still ongoing. It all started with the increased demand for smartphone applications, their success forcing developers to adapt to new back-end technologies that could handle a multitude of simultaneous requests. JavaScript has always been identified as a client-side […]