How to install rkhunter to a cronjob

June 7, 2008 / Web Hosting

How to setup a daily scan report?

# vi /etc/cron.daily/rkhunter.sh

#!/bin/bash
(/usr/local/bin/rkhunter -c –cronjob 2>&1 | mail -s “Daily Rkhunter Scan Report” [email protected])

#chmod x /e
#chmod x /etc/cron.daily/rkhunter.sh

#rkhunter –update

rkhunter (Rootkit Hunter) is a security tool that scans your system for rootkits, backdoors, and other security vulnerabilities. Setting up a cronjob for RKHunter ensures that regular scans are performed automatically. Here’s a step-by-step guide on how to install and set up RKHunter with a cronjob:

  1. Install RKHunter:
    On Debian/Ubuntu-based systems:sudo apt update
    sudo apt install rkhunter

    On Red Hat/Fedora-based systems:

    sudo dnf install rkhunter

  2. Update RKHunter:
    Make sure to update RKHunter regularly to get the latest security definitions:sudo rkhunter –update
  3. Configure RKHunter:
    Edit the configuration file to suit your system:

    sudo nano /etc/rkhunter.conf

    Review the settings in the configuration file. You may want to customize some options based on your system’s needs. Save the changes.

  4. Create a Cronjob:
    Open the cron table for editing:sudo crontab -e

    Add the following line to run RKHunter daily. This example runs the scan at 3:00 AM every day. Adjust the timing as needed:

    0 3 * * * /usr/bin/rkhunter –cronjob –update –quiet

    Save the changes.

  5. Verify the Cronjob:
    After saving the cronjob, you can verify it by listing the current crontab entries:sudo crontab -l

    Ensure that your RKHunter cronjob is listed.

  6. Test RKHunter:
    Run RKHunter manually to make sure it works as expected:sudo rkhunter –check

    Address any warnings or issues that RKHunter identifies.

That’s it! Now RKHunter will automatically run daily at the specified time and report any potential security threats. Keep in mind that RKHunter is just one tool in your security toolkit, and it’s essential to use multiple tools and practices to ensure the overall security of your system.