1. Tripwire
1.1 Installation, Configuration
① Install
# zypper -n install tripwire
② Creating a Local Key Passphrase
# twadmin --generate-keys -L /etc/tripwire/${HOSTNAME}-local.key
(When selecting a passphrase, keep in mind that good passphrases typically
have upper and lower case letters, digits and punctuation marks, and are
at least 8 characters in length.)
Enter the local keyfile passphrase: [Password]
Verify the local keyfile passphrase: [Password]
Generating key (this may take several minutes)...Key generation complete.
③Creating a Site Key Passphrase
# twadmin --generate-keys -S /etc/tripwire/site.key
(When selecting a passphrase, keep in mind that good passphrases typically
have upper and lower case letters, digits and punctuation marks, and are
at least 8 characters in length.)
Enter the site keyfile passphrase: [Password]
Verify the site keyfile passphrase: [Password]
Generating key (this may take several minutes)...Key generation complete.
④ Tripwire Settings
# vi /etc/tripwire/twcfg.txt
Add to the last line
LOOSEDIRECTORYCHECKING =true
REPORTLEVEL =4
⑤create a Tripwire configuration file (cryptographically signed version)
# twadmin -m F -c /etc/tripwire/tw.cfg -S /etc/tripwire/site.key /etc/tripwire/twcfg.txt
Please enter your site passphrase: ← [Site Passphrase]
Wrote configuration file: /etc/tripwire/tw.cfg
Delete Tripwire configuration file (text version)
# rm -f /etc/tripwire/twcfg.txt
※Restoring the Tripwire configuration file (text version)
# twadmin -m f -c /etc/tripwire/tw.cfg > /etc/tripwire/twcfg.txt
⑥ Policy File Text Version Creation
# vi /etc/tripwire/twpol.txt
@@section GLOBAL
TWROOT=/usr/sbin;
TWBIN=/usr/sbin;
TWPOL=/etc/tripwire;
TWDB=/var/lib/tripwire;
TWSKEY=/etc/tripwire;
TWLKEY=/etc/tripwire;
TWREPORT=/var/lib/tripwire/report;
HOSTNAME=myhostname;
Device = +pugsdr-intlbamcCMSH ;
Dynamic = +pinugtd-srlbamcCMSH ;
Growing = +pinugtdl-srbamcCMSH ;
IgnoreAll = -pinugtsdrlbamcCMSH ;
IgnoreNone = +pinugtsdrbamcCMSH-l ;
ReadOnly = +pinugtsdbmCM-rlacSH ;
Temporary = +pugt ;
@@section FS
(
rulename = "Tripwire Binaries",
)
{
$(TWBIN)/siggen -> $(ReadOnly) ;
$(TWBIN)/tripwire -> $(ReadOnly) ;
$(TWBIN)/twadmin -> $(ReadOnly) ;
$(TWBIN)/twprint -> $(ReadOnly) ;
}
(
rulename = "Tripwire Data Files",
)
{
$(TWDB) -> $(Dynamic) -i ;
$(TWPOL)/tw.pol -> $(ReadOnly) -i ;
$(TWPOL)/tw.cfg -> $(ReadOnly) -i ;
$(TWLKEY)/$(HOSTNAME)-local.key -> $(ReadOnly) ;
$(TWSKEY)/site.key -> $(ReadOnly) ;
# don't scan the individual reports
$(TWREPORT) -> $(Dynamic) (recurse=0) ;
}
(
rulename = "Global Configuration Files",
)
{
/etc -> $(IgnoreNone) -SHa ;
}
(
rulename = "OS Boot Files and Mount Points",
)
{
/boot -> $(ReadOnly) ;
}
(
rulename = "OS Devices and Misc Directories",
)
{
/opt -> $(Dynamic) ;
}
(
rulename = "OS Binaries and Libraries",
)
{
/bin -> $(ReadOnly) ;
/lib -> $(ReadOnly) ;
/lib64 -> $(ReadOnly) ;
/sbin -> $(ReadOnly) ;
/usr/bin -> $(ReadOnly) ;
/usr/lib -> $(ReadOnly) ;
/usr/lib64 -> $(ReadOnly) ;
/usr/sbin -> $(ReadOnly) ;
}
(
rulename = "User Binaries and Libraries",
)
{
/usr/local -> $(ReadOnly) ;
/usr/local/bin -> $(ReadOnly) ;
/usr/local/etc -> $(ReadOnly) ;
/usr/local/include -> $(ReadOnly) ;
/usr/local/lib -> $(ReadOnly) ;
/usr/local/sbin -> $(ReadOnly) ;
/usr/local/share -> $(ReadOnly) ;
}
(
rulename = "Root Directory and Files",
)
{
/root -> $(IgnoreNone) -SHa ;
}
(
rulename = "Monitor Filesystems",
)
{
/home -> $(ReadOnly) ; # Modify as needed
/usr -> $(ReadOnly) ;
/var -> $(ReadOnly) ;
}
⑦Policy File Settings
# cd /etc/tripwire/
# vi twpolmake.pl
Contents of twpolmake.pl
#!/usr/bin/perl
#
$POLFILE=$ARGV[0];
open(POL,"$POLFILE") or die "open error: $POLFILE" ;
my($myhost,$thost) ;
my($sharp,$tpath,$cond) ;
my($INRULE) = 0 ;
while (<POL>) {
chomp;
if (($thost) = /^HOSTNAME\s*=\s*(.*)\s*;/) {
$myhost = `hostname` ; chomp($myhost) ;
if ($thost ne $myhost) {
$_="HOSTNAME=\"$myhost\";" ;
}
}
elsif ( /^{/ ) {
$INRULE=1 ;
}
elsif ( /^}/ ) {
$INRULE=0 ;
}
elsif ($INRULE == 1 and ($sharp,$tpath,$cond) = /^(\s*\#?\s*)(\/\S+)\b(\s+->\s+.+)$/) {
$ret = ($sharp =~ s/\#//g) ;
if ($tpath eq '/sbin/e2fsadm' ) {
$cond =~ s/;\s+(tune2fs.*)$/; \#$1/ ;
}
if (! -s $tpath) {
$_ = "$sharp#$tpath$cond" if ($ret == 0) ;
}
else {
$_ = "$sharp$tpath$cond" ;
}
}
print "$_\n" ;
}
close(POL) ;
⑧Policy File Optimizations
# perl /etc/tripwire/twpolmake.pl /etc/tripwire/twpol.txt > /etc/tripwire/twpol.txt.new
⑨Create policy file (cryptographically signed version) based on optimized policy file
# twadmin -m P -c /etc/tripwire/tw.cfg -p /etc/tripwire/tw.pol -S /etc/tripwire/site.key /etc/tripwire/twpol.txt.new
Please enter your site passphrase: ←Enter your site passphrase
Wrote policy file: /etc/tripwire/tw.pol
⑩ Create database and check operation
# tripwire --init
Please enter your local passphrase: ←Enter your local passphrase
Parsing policy file: /etc/tripwire/tw.pol
Generating the database...
*** Processing Unix File System ***
The object: "/var/lib/snapd/snap/certbot/5940" is on a different file system...ignoring.
The object: "/var/lib/snapd/snap/core24/2307" is on a different file system...ignoring.
The object: "/var/lib/snapd/snap/snapd/28332" is on a different file system...ignoring.
The object: "/boot/grub2/i386-pc" is on a different file system...ignoring.
The object: "/boot/grub2/x86_64-efi" is on a different file system...ignoring.
Wrote database file: /var/lib/tripwire/Lepard.twd
The database was successfully generated.
⑪Create test files
# echo test > /root/test.txt
# tripwire --check
If successful, it will display as follows:
Parsing policy file: /etc/tripwire/tw.pol
*** Processing Unix File System ***
Performing integrity check...
The object: "/var/lib/snapd/snap/certbot/5940" is on a different file system...ignoring.
The object: "/var/lib/snapd/snap/core24/2307" is on a different file system...ignoring.
The object: "/var/lib/snapd/snap/snapd/28332" is on a different file system...ignoring.
The object: "/boot/grub2/i386-pc" is on a different file system...ignoring.
The object: "/boot/grub2/x86_64-efi" is on a different file system...ignoring.
Wrote report file: /var/lib/tripwire/report/Lepard-20261119-084928.twr
Open Source Tripwire(R) 2.4.3.7 Integrity Check Report
Report generated by: root
Report created on: Thu 19 Nov 2026 08:49:28 AM JST
Database last updated on: Never
===============================================================================
Report Summary:
===============================================================================
Host name: Lepard
Host IP address: Unknown IP
Host ID: None
Policy file used: /etc/tripwire/tw.pol
Configuration file used: /etc/tripwire/tw.cfg
Database file used: /var/lib/tripwire/Lepard.twd
Command line used: tripwire --check
===============================================================================
Rule Summary:
===============================================================================
-------------------------------------------------------------------------------
Section: Unix File System
-------------------------------------------------------------------------------
Rule Name Severity Level Added Removed Modified
--------- -------------- ----- ------- --------
* Monitor Filesystems 0 0 0 9
OS Binaries and Libraries 0 0 0 0
Tripwire Binaries 0 0 0 0
User Binaries and Libraries 0 0 0 0
(/usr/local)
* Tripwire Data Files 0 1 0 0
Global Configuration Files 0 0 0 0
(/etc)
OS Boot Files and Mount Points 0 0 0 0
(/boot)
* Root Directory and Files 0 1 0 0
(/root)
Total objects scanned: 88563
Total violations found: 11
===============================================================================
Object Summary:
===============================================================================
-------------------------------------------------------------------------------
# Section: Unix File System
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
Rule Name: Monitor Filesystems (/var)
Severity Level: 0
-------------------------------------------------------------------------------
Modified:
"/var/lib/nagios/status.dat"
"/var/log/apache2/suse.korodes.com.access.log"
"/var/log/journal/fdf2421d0293444c92a13fbe31fd26c7/system.journal"
"/var/log/mail"
"/var/log/mail.info"
"/var/log/messages"
"/var/log/suricata/eve.json"
"/var/log/suricata/stats.log"
"/var/log/vmware-vmsvc-root.log"
-------------------------------------------------------------------------------
Rule Name: Tripwire Data Files (/var/lib/tripwire)
Severity Level: 0
-------------------------------------------------------------------------------
Added:
"/var/lib/tripwire/Lepard.twd"
-------------------------------------------------------------------------------
Rule Name: Root Directory and Files (/root)
Severity Level: 0
-------------------------------------------------------------------------------
Added:
"/root/test.txt"
===============================================================================
Error Report:
===============================================================================
No Errors
-------------------------------------------------------------------------------
*** End of report ***
Open Source Tripwire 2.4 Portions copyright 2000-2018 Tripwire, Inc. Tripwire is a registered
trademark of Tripwire, Inc. This software comes with ABSOLUTELY NO WARRANTY;
for details use --version. This is free software which may be redistributed
or modified only under certain conditions; see COPYING for details.
All rights reserved.
Integrity check complete.
Delete test files
# rm -f /root/test.txt
1.2 Schedule Tripwire to run regularly
①Creating an Automated Script for Tripwire Email Notifications
# cd /srv/www/system
# vi tripwire.sh
Contents of "tripwire.sh"
Enter the local passphrase and site passphrase you set for each of LOCALPASS and SITEPASS in the "xxxxxxxx" fields.
#!/bin/bash
PATH=/usr/sbin:/usr/bin:/bin:/usr/local/tripwire/sbin
# Passphrase Setup
LOCALPASS=xxxxx # Local passphrase
SITEPASS=xxxxx # Site passphrase
#Specify notification email address
MAIL="mail address"
cd /etc/tripwire
# Tripwire Check Execution
tripwire -m c -s -c tw.cfg|mail -s "Tripwire(R) Integrity Check Report in `hostname`" $MAIL
# Policy File Update
twadmin --create-polfile -S /etc/tripwire/site.key -Q $SITEPASS /etc/tripwire/twpol.txt
rm -f twpol.txt* *.bak
# Database Update
rm -f /var/lib/tripwire/*.twd*
tripwire --init -P $LOCALPASS
# chmod 700 tripwire.sh
②Add Tripwire to cron so it runs regularly
# crontab -e
0 3 * * * /srv/www/system/tripwire.sh
Execute the following command and verify that a notification is delivered to the specified email address.
# /srv/www/system/tripwire.sh
2. Logwatch
① Logwatch Installation
# zypper -n install logwatch
② Edit configuration file
Copy the sample files to the installation directory.
# cat /usr/share/logwatch/default.conf/logwatch.conf >> /etc/logwatch/conf/logwatch.conf
# vi /etc/logwatch/conf/logwatch.conf
Line 77 : add Set the email address where you want to receive notifications
#MailTo = root
MailTo = <mail.address>
Line 116 : add Set the level of detail for log notifications
#Detail = Low
Detail = High
③ Output Logwatch reports
# logwatch --output stdout
################### Logwatch 7.15 (07/22/26) ####################
Processing Initiated: Thu Nov 19 09:31:07 2026
Date Range Processed: yesterday
( 2026-Nov-18 )
Period is day.
Detail Level of Output: 10
Type of Output/Format: stdout / text
Logfiles for Host: Lepard
##################################################################
------------------------Omit----------------------------------
--------------------- lm_sensors output Begin ------------------------
No sensors found!
Make sure you loaded all the kernel drivers you need.
Try sensors-detect to find out which these are.
---------------------- lm_sensors output End -------------------------
###################### Logwatch End #########################
If you see something like this, rewrite the Perl for that line
This is a warning about operator precedence added in Perl 5.42 and later. Logical negation operator! This occurs because the precedence of is higher than the comparison operator.
Possible precedence problem between ! and string eq at /usr/lib/perl5/vendor_perl/5.42.1/Date/Manip/Delta.pm line 2712.
Possible precedence problem between ! and string eq at /usr/lib/perl5/vendor_perl/5.42.1/Date/Manip/Delta.pm line 1117.
Rewrite it as follows
# vi /usr/lib/perl5/vendor_perl/5.42.1/Date/Manip/Date.pm
Line 2712 :
if (! ref($date) eq 'Date::Manip::Date') { → if (! (ref($date) eq 'Date::Manip::Date')) {
# vi /usr/lib/perl5/vendor_perl/5.42.1/Date/Manip/Delta.pm
Line 1117 :
if (! ref($delta) eq 'Date::Manip::Delta') { → if (! (ref($delta) eq 'Date::Manip::Delta')) {
④ Test whether the report arrives at the address you set
# logwatch --output mail
You will now receive a report at the email address you specified
