You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* 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
Copy file name to clipboardExpand all lines: docs/guides/web/apache_hardened_webserver/rkhunter.md
+36-18Lines changed: 36 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: Rootkit Hunter
3
3
author: Steven Spencer
4
4
contributors: Ezequiel Bruni
5
-
tested with: 8.5
5
+
tested with: 8.7, 9.1
6
6
tags:
7
7
- server
8
8
- security
@@ -18,57 +18,75 @@ tags:
18
18
* An understanding of what can trigger a response to changed files on the file system (such as package updates) is helpful
19
19
* All commands are run as the root user or sudo
20
20
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.
22
22
23
23
## Introduction
24
24
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.
26
26
27
27
_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).
28
28
29
29
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.
30
30
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
+
31
39
## Installing rkhunter
32
40
33
41
_rkhunter_ requires the EPEL (Extra Packages for Enterprise Linux) repository. So install that repository if you don't have it installed already:
34
42
35
-
`dnf install epel-release`
43
+
```
44
+
dnf install epel-release
45
+
```
36
46
37
47
Then install _rkhunter_:
38
48
39
-
`dnf install rkhunter`
49
+
```
50
+
dnf install rkhunter
51
+
```
40
52
41
53
## Configuring rkhunter
42
54
43
55
The only configuration options that need to be set are those dealing with mailing reports to the administrator. To modify the configuration file, run:
44
56
45
-
`vi /etc/rkhunter.conf`
57
+
```
58
+
vi /etc/rkhunter.conf`
59
+
```
46
60
47
61
And then search for:
48
62
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`.
50
70
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:
52
72
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
+
```
54
76
55
77
You may also need to setup [Postfix Email for Reporting](../../email/postfix_reporting.md) in order to get the email section to work correctly.
56
78
57
79
## Running rkhunter
58
80
59
81
_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).
60
82
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.
68
84
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:
70
86
71
-
This will echo back to the screen as the checks are performed, prompting you to `[Press <ENTER> to continue]` after each section.
0 commit comments