
Tripwire is an Intrusion Detection System. It monitors the server's filesystem and detects unauthorized changes to files and directories.
This guide shows you how to install Tripwire, configure a basic list of files to monitor for changes, and automate the Tripwire filesystem scan.
This guide is for Open Source Tripwire; do not confuse Open Source Tripwire with the commercial version of Tripwire, which is a different software package.
Install Tripwire.
During installation, you are prompted to create site keys and local keys. Select No at both prompts; you will generate the keys manually in the next step.
Tripwire's policy, database, and configuration files are signed by site keys and local keys, which are protected by passphrases. This ensures that your Tripwire configuration cannot be changed without the passphrase.
Make sure you choose memorable and secure passphrases for both keys. You will need them whenever you edit the Tripwire policy or configuration.
Generate the local key.
Generate the site key.
Open the configuration file /etc/tripwire/twcfg.txt and edit the following lines to include your site and local keys:
Use twadmin to sign the edited configuration file.
Tripwire prompts you to enter the site key's passphrase. It then saves the signed configuration file to /etc/tripwire/tw.cfg.
If you make changes to the configuration file in the future, you must re-sign it with the site key.
The policy file specifies which directories and files will be monitored for changes. A default policy is provided with Tripwire, but it is complex. You will create a basic policy for this guide which only monitors the /etc directory.
Move the default policy to a different file.
Create a new policy file called /etc/tripwire/twpol.txt and add the following rule to it:
This rule tells Tripwire to scan the entire /etc directory, and to treat the files inside as read-only.
Sign the policy file using the site key.
Tripwire prompts you to enter the site key's passphrase. It then saves the signed policy file to /etc/tripwire/tw.pol.
If you make changes to the policy file in the future, you must re-sign it with the site key.
Tripwire maintains a database of files, which it uses to run checks. Whenever you edit a policy, you should re-generate the database.
Generate the initial Tripwire database.
Tripwire prompts you to enter the local key's passphrase.
You are now ready to run a filesystem check.
Tripwire generates a filesystem report and saves it as report.twr in your current working directory. It also outputs a plain text version of the report to the terminal. You should see in the Rule Summary section that no files have been added, removed, or modified.
To test your policy, create a new file in the /etc directory.
Re-run the Tripwire check.
You should now see that Tripwire detects the file /etc/test.txt, and lists it in the report.
You can now update the Tripwire database to include the new file, which will prevent it from appearing on future reports.
Cron is a task scheduler that is used to run programs automatically.
Edit the root crontab file.
Add the following line, which will run hourly Tripwire checks on the server.
Cron sends the command output to the mail file /var/mail/mail. Tripwire stores the reports it generates in /var/lib/tripwire/report/, which you can use to update the Tripwire database.
You can learn more about using cron to schedule tasks in this Vultr Docs article.
Now that you have installed and configured Tripwire, you should consider which other files on your server need to be monitored for changes and add them to the policy file. You can learn how to write more advanced policies and find examples on the Tripwire GitHub repository.
0 Comments
Be the first to comment and share your perspective with the community.