Rootkit hunter (rkhunter) is a well known tool for checking vulnerabilities, rootkits, back doors, and possible local exploits on a server. It is possible to use it on any server used for any purpose. When tuned and automated, it can report any suspicious activity to the system administrator. This procedure outlines the installation, tuning, and use of rootkit hunter.
Proficiency with a command-line editor (using vi in this example)
A comfort level with issuing commands from the command-line, viewing logs, and other general systems administrator duties
An understanding of what can trigger a response to changed files on the file system (such as package updates) is helpful
Running all commands as root or as a regular user with sudo
This document was originally written in conjunction with the apache hardened web server routines, but works equally well on a server running any software.
rkhunter (Root Kit Hunter) is a Unix-based tool that scans for rootkits, back doors, and possible local exploits. It is a good part of a hardened server, and will notify the administrator quickly when something suspicious happens on the server's file system, providing it is properly configured.
rkhunter is just one possible part of a hardened Apache web server setup. Use it alone or with other tools to maximize security. If you want to use this along with other tools for hardening, refer back to the Apache Hardened Web Server guide.
This document also uses all of the assumptions and conventions outlined in that original document. It is a good idea to review it before continuing.
The only configuration options that you need to set are those dealing with mailing reports to the Administrator.
Warning
Modification of any configuration file in Linux carries risk. Before altering any configuration file in Linux, creating a backup of the original file is recommended.
To change the configuration file, run:
vi /etc/rkhunter.conf
Search for:
#MAIL-ON-WARNING=me@mydomain root@mydomain
Remove the remark here and change the me@mydomain.com to reflect your email address.
Change the root@mydomain to root@whatever_the_server_name_is.
You will probably also want to remove the remark (and edit the line to fit your needs) from the MAIL-CMD line:
MAIL_CMD=mail -s "[rkhunter] Warnings found for ${HOST_NAME}"
Run rkhunter manually by typing it at the command-line. A cron job takes care of running rkhunter for you automatically in /etc/cron.daily. If you want to automate the procedure on a different schedule, examine Automating cron jobs guide.
You will also need to move the script somewhere other than /etc/cron.daily/, such as /usr/local/sbin/ and call it from your custom cron job. The easiest method is to leave the default cron.daily setup intact.
If you want to test rkhunter before you start, including all email functionality, run rkhunter --check from the command line. If installed and functioning correctly, you should receive an output similar to the following:
Hold off completing the remaining steps if problems exist with the email setup. When confirming email works, but before allowing rkhunter to run automatically, run the command manually again with the "--propupd" flag to create the rkhunter.dat file. This ensures recognition of your environment and configuration:
rkhunter is one part of a hardened server strategy that can help monitor the file system and report any issues to the administrator. It is perhaps one of the easiest hardening tools to install, configure, and run.
Author: Steven Spencer
Contributors: Ezequiel Bruni, Andrew Thiesen, Ganna Zhyrnova