Skip to content

Commit a211464

Browse files
authored
# update for 2023 (#1116)
* modify the configuration section slightly * specific instructions for testing your rkhunter setup using `rkhunter --check` * updated the "tested with" in the meta to reflect it working correctly with the latest Rocky versions * added a "General Steps" section as a quick reference of the steps to take and brief description where necessary
1 parent 7750aa5 commit a211464

File tree

1 file changed

+36
-18
lines changed

1 file changed

+36
-18
lines changed

docs/guides/web/apache_hardened_webserver/rkhunter.md

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Rootkit Hunter
33
author: Steven Spencer
44
contributors: Ezequiel Bruni
5-
tested with: 8.5
5+
tested with: 8.7, 9.1
66
tags:
77
- server
88
- security
@@ -18,57 +18,75 @@ tags:
1818
* An understanding of what can trigger a response to changed files on the file system (such as package updates) is helpful
1919
* All commands are run as the root user or sudo
2020

21-
This document was originally written in conjunction with the apache hardened webserver routines, but works equally well in a server running any software.
21+
This document was originally written in conjunction with the apache hardened webserver routines, but works equally well on a server running any software.
2222

2323
## Introduction
2424

25-
_rkhunter_ (Root Kit Hunter) is a Unix-based tool that scans for rootkits, backdoors, and possible local exploits. It is a good part of a hardened web server, and is designed to notify the administrator quickly when something suspicious happens on the server's file system.
25+
_rkhunter_ (Root Kit Hunter) is a Unix-based tool that scans for rootkits, backdoors, and possible local exploits. It is a good part of a hardened server, and is designed to notify the administrator quickly when something suspicious happens on the server's file system.
2626

2727
_rkhunter_ is just one possible component of a hardened Apache web server setup and can be used with or without other tools. If you'd like to use this along with other tools for hardening, refer back to the [Apache Hardened Web Server guide](index.md).
2828

2929
This document also uses all of the assumptions and conventions outlined in that original document, so it is a good idea to review it before continuing.
3030

31+
## General steps
32+
33+
1. install rkhunter
34+
2. configure rkhunter
35+
3. configure email and make sure it is set up to work correctly
36+
4. run `rkhunter` manually to generate a list of warnings to test your email settings (`rkhunter --check`)
37+
5. run `rkhunter --propupd` to generate a clean `rkhunter.dat` file that `rkhunter` will use from this point forward as a baseline for further checks.
38+
3139
## Installing rkhunter
3240

3341
_rkhunter_ requires the EPEL (Extra Packages for Enterprise Linux) repository. So install that repository if you don't have it installed already:
3442

35-
`dnf install epel-release`
43+
```
44+
dnf install epel-release
45+
```
3646

3747
Then install _rkhunter_:
3848

39-
`dnf install rkhunter`
49+
```
50+
dnf install rkhunter
51+
```
4052

4153
## Configuring rkhunter
4254

4355
The only configuration options that need to be set are those dealing with mailing reports to the administrator. To modify the configuration file, run:
4456

45-
`vi /etc/rkhunter.conf`
57+
```
58+
vi /etc/rkhunter.conf`
59+
```
4660

4761
And then search for:
4862

49-
`#MAIL-ON-WARNING=me@mydomain root@mydomain`
63+
```
64+
#MAIL-ON-WARNING=me@mydomain root@mydomain
65+
```
66+
67+
Remove the remark here and change the `[email protected]` to reflect your email address.
68+
69+
Then change the `root@mydomain` to `root@whatever_the_server_name_is`.
5070

51-
Remove the remark here and change the [email protected] to reflect your email address.
71+
You will probably also want to remove the remark (and edit the line to fit your needs) of the `MAIL-CMD` line, found a few lines below that looks like this:
5272

53-
Then change the root@mydomain to root@whatever_the_server_name_is.
73+
```
74+
MAIL_CMD=mail -s "[rkhunter] Warnings found for ${HOST_NAME}"
75+
```
5476

5577
You may also need to setup [Postfix Email for Reporting](../../email/postfix_reporting.md) in order to get the email section to work correctly.
5678

5779
## Running rkhunter
5880

5981
_rkhunter_ can be run by typing it at the command-line. There is a cron job installed for you in `/etc/cron.daily`, but if you want to automate the procedure on a different schedule, look at the [Automating cron jobs guide](../../automation/cron_jobs_howto.md).
6082

61-
You'll also need to move the script somewhere other than `/etc/cron.daily`, such as `/usr/local/sbin` and then call it from your custom cron job. The easiest method, of course, is to leave the default cron.daily setup intact.
62-
63-
Before you run allow _rkhunter_ to run automatically, run the command manually with the "--propupd" flag to create the rkhunter.dat file, and to make sure that your new environment is recognized without issue:
64-
65-
`rkhunter --propupd`
66-
67-
To run _rkhunter_ manually:
83+
You'll also need to move the script somewhere other than `/etc/cron.daily`, such as `/usr/local/sbin` and then call it from your custom cron job. The easiest method, of course, is to leave the default `cron.daily` setup intact.
6884

69-
`rkhunter --check`
85+
If you want to test `rkhunter` before you start, including all email functionality, etc., run `rkhunter --check` from the command line. If there are problems with email setup, hold off completing the rest so that you can run this command again. Once email has been confirmed to work but before you allow `rkhunter` to run automatically, run the command manually again with the "--propupd" flag to create the `rkhunter.dat` file, and to make sure that your new environment is recognized without issue:
7086

71-
This will echo back to the screen as the checks are performed, prompting you to `[Press <ENTER> to continue]` after each section.
87+
```
88+
rkhunter --propupd
89+
```
7290

7391
## Conclusion
7492

0 commit comments

Comments
 (0)