{"id":6636,"date":"2020-08-05T22:59:56","date_gmt":"2020-08-05T19:59:56","guid":{"rendered":"https:\/\/kifarunix.com\/?p=6636"},"modified":"2024-03-14T22:42:03","modified_gmt":"2024-03-14T19:42:03","slug":"install-and-setup-lynis-security-auditing-tool-on-centos-8","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-and-setup-lynis-security-auditing-tool-on-centos-8\/","title":{"rendered":"Install and Setup Lynis Security Auditing tool on CentOS 8"},"content":{"rendered":"\n
In this tutorial, you will learn how to install and setup Lynis security auditing tool on CentOS 8. Lynis<\/a> is an open-source security tool that can perform an in-depth system security scan in order to evaluate the system\u2019s security profile. Due to its simplicity and flexibility, Lynis can be used to achieve the following;<\/p>\n\n\n\n Lynis, however, doesn\u2019t provide system hardening automatically but instead provide tips on how to harden your system.<\/p>\n\n\n\n It is a cross platform tool and it was designed for systems running Linux, macOS, or Unix-based operating system.<\/p>\n\n\n\n Lynis can be installed on a CentOS system by cloning their Github repos, using the source tarball or by simply pulling it from the package repositories using the package manager.<\/p>\n\n\n\n You can use EPEL repos or Lynis Software community repos for CentOS to install Lynis on CentOS 8.<\/p>\n\n\n\n Install EPEL repos by running the command below;<\/p>\n\n\n\n Check what provides Lynis;<\/p>\n\n\n\n Well, proceed to install Lynis on CentOS 8<\/p>\n\n\n\n Install Lynis Software community repos for Lynis on CentOS 8;<\/p>\n\n\n\n Run package updates;<\/p>\n\n\n\n Update the cURL, NSS, openssl, and CA-certificates packages;<\/p>\n\n\n\n Install Lynis;<\/p>\n\n\n\n Check the version of installed Lynis;<\/p>\n\n\n\n The Lynis command syntax is<\/p>\n\n\n\n To show Lynis commands, run;<\/p>\n\n\n\n To show Lynis Settings run;<\/p>\n\n\n\n To show discovered audit profiles;<\/p>\n\n\n\n Lynis security auditing tool checks the system and the software configuration, to see if there is any room for improvement the security defenses.<\/p>\n\n\n\n The Lynis test and debug information are logged in The following system areas may be checked by Lynis:<\/p>\n\n\n\n Lynis can run interactively or as a cronjob. Root permissions (e.g. sudo) are not required, however they provide more details during the audit.<\/p>\n\n\n\n To run a basic system audit with Lynis execute the command below;<\/p>\n\n\n\n When it runs, it display various checks and results to the standard output as well as writing to the log and reports file;<\/p>\n\n\n\n The output of the Lynis may show OK or WARNING with OK meaning the checks are okay while WARNING shows an identified issue in the system that requires attention.<\/p>\n\n\n\n Summary of the system audit checks;<\/p>\n\n\n\n As you can see, we have two warnings and 46 other suggestions.<\/p>\n\n\n\n Go through the suggested solutions to find how to implement various system hardenings.<\/p>\n\n\n\n From this section, you will see;<\/p>\n\n\n\n Apart from being written to the stdout, the Lynis scan report is also written to From this report, you can read the warnings and suggestions given<\/p>\n\n\n\n To check the suggestions;<\/p>\n\n\n\n Every Lynis system check has an associated test ID. To find more about an specific check, you can show the details using the command below.<\/p>\n\n\n\n Take for example, let us check more about the system reboot warning above;<\/p>\n\n\n\n Lynis uses profiles to have a set of predefined options for your operating system and preferences. The default profiles are stored under If you want to use a custom profile, use the To create your own custom profile, you can copy the default profile and edit it to define your custom test options.<\/p>\n\n\n\n When run with no further options defined, the default profile, If you consider some checks as false positives, you can create a custom profile where you can define the test ID that Lynis should skip while running the system scan<\/p>\n\n\n\n For instance, to skip the suggestion below;<\/p>\n\n\n\n Create a custom profile and put the following contents.<\/p>\n\n\n\n When you run the Lynis audit scan next time, the specified checks will be skipped.<\/p>\n\n\n\n Lynis is a useful tool. Go through all the fixes and suggestions provided to harden your system.<\/p>\n\n\n\n Get Started with Lynis<\/a><\/p>\n\n\n\n Lynis \u2013 Security auditing tool for Linux, macOS, and UNIX-based systems<\/a><\/p>\n\n\n\n Install and Setup Lynis Security Auditing tool on Ubuntu 20.04<\/a><\/p>\n\n\n\n How to Perform System Security Auditing with Lynis on Ubuntu 18.04<\/a><\/p>\n\n\n\n Restrict Access to WordPress Login Page to Specific IPs with libModSecurity<\/a><\/p>\n\n\n\n Install and use ClamAV on Ubuntu 20.04<\/a><\/p>\n\n\n\n How to Install and Configure Maltrail on Ubuntu 18.04<\/a><\/p>\n\n\n\n\n
Installing Lynis Security Auditing tool on CentOS 8<\/h2>\n\n\n\n
Install Lynis from Software Repository<\/h3>\n\n\n\n
Installing Lynis from EPEL Repos<\/h4>\n\n\n\n
dnf install epel-release<\/code><\/pre>\n\n\n\n
dnf provides lynis<\/code><\/pre>\n\n\n\n
lynis-3.0.0-1.el8.noarch : Security and system auditing tool\nRepo : epel\nMatched from:\nProvide : lynis = 3.0.0-1.el8<\/code><\/pre>\n\n\n\n
dnf install lynis<\/code><\/pre>\n\n\n\n
Install Lynis Community repos for CentOS<\/h4>\n\n\n\n
cat << 'EOL' > \/etc\/yum.repos.d\/cisofy-lynis.repo\n[lynis]\nname=CISOfy Software - Lynis package\nbaseurl=https:\/\/packages.cisofy.com\/community\/lynis\/rpm\/\nenabled=1\ngpgkey=https:\/\/packages.cisofy.com\/keys\/cisofy-software-rpms-public.key\ngpgcheck=1\npriority=2\nEOL<\/code><\/pre>\n\n\n\n
dnf update<\/code><\/pre>\n\n\n\n
dnf update curl nss openssl ca-certificates<\/code><\/pre>\n\n\n\n
dnf install lynis<\/code><\/pre>\n\n\n\n
Dependencies resolved.\n============================================================================================================================================================================\n Package Architecture Version Repository Size\n============================================================================================================================================================================\nInstalling:\n lynis noarch 3.0.0-100 lynis 312 k\n\nTransaction Summary\n============================================================================================================================================================================\nInstall 1 Package\n\nTotal download size: 312 k\nInstalled size: 1.5 M\nIs this ok [y\/N]: y<\/code><\/pre>\n\n\n\n
lynis show version<\/code><\/pre>\n\n\n\n
3.0.0<\/code><\/pre>\n\n\n\n
Lynis Command Line Syntax and Options<\/h3>\n\n\n\n
lynis [scan mode] [other options]<\/code><\/pre>\n\n\n\n
lynis show commands<\/code><\/pre>\n\n\n\n
Commands:\nlynis audit\nlynis configure\nlynis generate\nlynis show\nlynis update\nlynis upload-only<\/code><\/pre>\n\n\n\n
lynis show settings<\/code><\/pre>\n\n\n\n
lynis show profiles<\/code><\/pre>\n\n\n\n
\/etc\/lynis\/default.prf<\/strong><\/code><\/pre>\n\n\n\n
Perform System Audit using Lynis on CentOS 8<\/h3>\n\n\n\n
\/var\/log\/lynis.log<\/code> <\/strong>while the audit report data is stored in:
\/var\/log\/lynis-report.dat<\/code><\/strong>.<\/p>\n\n\n\n
\/var\/log\/lynis.log<\/code><\/strong> is the file an auditor has to check and interpret the results as it explains the reason for the issues identified as well suggestions on how to fix those issues.<\/p>\n\n\n\n
\n
Perform System Audit with Lynis on CentOS 8<\/h4>\n\n\n\n
lynis audit system<\/code><\/pre>\n\n\n\n
...\n+] Software: e-mail and messaging\n------------------------------------\n\n[+] Software: firewalls\n------------------------------------\n - Checking iptables kernel module [ FOUND ]\n - Checking iptables policies of chains [ FOUND ]\n - Checking for empty ruleset [ WARNING ]\n - Checking for unused rules [ OK ]\n - Checking host based firewall [ ACTIVE ]\n\n[+] Software: webserver\n------------------------------------\n - Checking Apache (binary \/usr\/sbin\/httpd) [ FOUND ]\n Info: Configuration file found (\/etc\/httpd\/conf\/httpd.conf)\n Info: No virtual hosts found\n * Loadable modules [ FOUND (106) ]\n - Found 106 loadable modules\n mod_evasive: anti-DoS\/brute force [ NOT FOUND ]\n mod_reqtimeout\/mod_qos [ FOUND ]\n ModSecurity: web application firewall [ NOT FOUND ]\n - Checking nginx [ NOT FOUND ]\n\n[+] SSH Support\n------------------------------------\n - Checking running SSH daemon [ FOUND ]\n - Searching SSH configuration [ FOUND ]\n - OpenSSH option: AllowTcpForwarding [ SUGGESTION ]\n - OpenSSH option: ClientAliveCountMax [ SUGGESTION ]\n - OpenSSH option: ClientAliveInterval [ OK ]\n - OpenSSH option: Compression [ SUGGESTION ]\n - OpenSSH option: FingerprintHash [ OK ]\n...<\/code><\/pre>\n\n\n\n
...\n================================================================================\n\n -[ Lynis 3.0.0 Results ]-\n\n Warnings (2):\n ----------------------------\n ! Reboot of system is most likely needed [KRNL-5830] \n - Solution : reboot\n https://cisofy.com\/lynis\/controls\/KRNL-5830\/\n\n ! iptables module(s) loaded, but no rules active [FIRE-4512] \n https:\/\/cisofy.com\/lynis\/controls\/FIRE-4512\/\n\n Suggestions (46):\n ----------------------------\n * This release is more than 4 months old. Consider upgrading [LYNIS] \n https:\/\/cisofy.com\/lynis\/controls\/LYNIS\/\n\n * If not required, consider explicit disabling of core dump in \/etc\/security\/limits.conf file [KRNL-5820] \n https:\/\/cisofy.com\/lynis\/controls\/KRNL-5820\/\n...<\/code><\/pre>\n\n\n\n
Lynis security scan details<\/h3>\n\n\n\n
\n
================================================================================\n\n Lynis security scan details:\n\n Hardening index : 63 [############ ]\n Tests performed : 241\n Plugins enabled : 0\n\n Components:\n - Firewall [V]\n - Malware scanner [X]\n\n Scan mode:\n Normal [V] Forensics [ ] Integration [ ] Pentest [ ]\n\n Lynis modules:\n - Compliance status [?]\n - Security audit [V]\n - Vulnerability scan [V]\n\n Files:\n - Test and debug information : \/var\/log\/lynis.log\n - Report data : \/var\/log\/lynis-report.dat\n\n================================================================================<\/code><\/pre>\n\n\n\n
Check Hardening Warnings and Suggestions from Lynis Audit report<\/h4>\n\n\n\n
\/var\/log\/lynis-report.dat<\/strong><\/code> report.<\/p>\n\n\n\n
grep -i \"^warning\" \/var\/log\/lynis-report.dat<\/code><\/pre>\n\n\n\n
warning[]=KRNL-5830|Reboot of system is most likely needed||text:reboot|\nwarning[]=FIRE-4512|iptables module(s) loaded, but no rules active|-|-|<\/code><\/pre>\n\n\n\n
grep -i \"^suggestion\" \/var\/log\/lynis-report.dat<\/code><\/pre>\n\n\n\n
...\nsuggestion[]=LYNIS|This release is more than 4 months old. Consider upgrading|-|-|\nsuggestion[]=KRNL-5820|If not required, consider explicit disabling of core dump in \/etc\/security\/limits.conf file|-|-|\nsuggestion[]=AUTH-9229|Check PAM configuration, add rounds if applicable and expire passwords to encrypt with new values|-|-|\nsuggestion[]=AUTH-9230|Configure minimum encryption algorithm rounds in \/etc\/login.defs|-|-|\nsuggestion[]=AUTH-9230|Configure maximum encryption algorithm rounds in \/etc\/login.defs|-|-|\nsuggestion[]=AUTH-9282|When possible set expire dates for all password protected accounts|-|-|\n...<\/code><\/pre>\n\n\n\n
Showing Details of a Specific Test<\/h4>\n\n\n\n
lynis show details TEST-ID<\/code><\/pre>\n\n\n\n
lynis show details KRNL-5830<\/code><\/pre>\n\n\n\n
2020-08-05 22:28:05 Performing test ID KRNL-5830 (Checking if system is running on the latest installed kernel)\n2020-08-05 22:28:05 Test: Checking presence \/var\/run\/reboot-required.pkgs\n2020-08-05 22:28:05 Result: file \/var\/run\/reboot-required.pkgs not found\n2020-08-05 22:28:05 Result: \/boot exists, performing more tests from here\n2020-08-05 22:28:05 Result: found \/boot\/vmlinuz-4.18.0-193.14.2.el8_2.x86_64\n2020-08-05 22:28:05 Test: checking kernel version on disk\n2020-08-05 22:28:05 Result: found version 4.18.0-193.14.2.el8_2.x86_64\n2020-08-05 22:28:05 Result: active kernel version 4.18.0-193.6.3.el8_2.x86_64\n2020-08-05 22:28:05 Result: reboot needed, as there is a difference between active kernel and the one on disk\n2020-08-05 22:28:05 Result: \/var\/cache\/apt\/archives\/ does not exist\n2020-08-05 22:28:05 Warning: Reboot of system is most likely needed [test:KRNL-5830] [details:] [solution:text:reboot]\n2020-08-05 22:28:05 Hardening: assigned partial number of hardening points (0 of 5). Currently having 12 points (out of 21)\n2020-08-05 22:28:05 Security check: file is normal\n2020-08-05 22:28:05 Checking permissions of \/usr\/share\/lynis\/include\/tests_memory_processes\n2020-08-05 22:28:05 File permissions are OK\n2020-08-05 22:28:05 ====<\/code><\/pre>\n\n\n\n
Lynis Audit Scanning Profiles<\/h4>\n\n\n\n
\/etc\/lynis<\/strong><\/code> directory.<\/p>\n\n\n\n
ls \/etc\/lynis<\/code><\/pre>\n\n\n\n
default.prf<\/code><\/pre>\n\n\n\n
\u2013profile <name> <\/strong><\/code>option with
lynis audit system<\/strong><\/code> command.<\/p>\n\n\n\n
lynis audit system --profile \/path\/to\/custom\/profile.prf<\/code><\/pre>\n\n\n\n
\/etc\/lynis\/default.prf<\/code> will be used.<\/p>\n\n\n\n
Disabling Specific Checks<\/h4>\n\n\n\n
suggestion[]=KRNL-5820|If not required, consider explicit disabling of core dump in \/etc\/security\/limits.conf file|-|-|<\/code><\/pre>\n\n\n\n
vim \/etc\/lynis\/custom.prf<\/code><\/pre>\n\n\n\n
# Lynis - Custom Scan Profile to ignore some warnings\n#\n# Ignore Vulnerable packages Warnings\nskip-test=KRNL-5820<\/code><\/pre>\n\n\n\n
Further Reading<\/h3>\n\n\n\n
Related Tutorials<\/h3>\n\n\n\n