samhain file integrity scanner | online documentation
This document aims to explain how to use samhain with signed configuration and database files which are checked by invoking GnuPG.
Samhain can be compiled to recognize PGP signatures on configuration and database files and to invoke GnuPG in order to check such signatures. (Note: while the application usually is referred to as GnuPG, the executable itself is called gpg).
If samhain is compiled with this option, then
Obviously you need gpg (GnuPG), and you must have created a key pair with:
gpg --gen-key
(it does not really matter which type of key, the defaults are ok).
GnuPG uses a public-key algorithm: the key pair consists of
The secret key obviously should be kept secret, while the public key can be published.
You need to compile samhain with support for GnuPG:
./configure --with-gpg=/path/to/gpg [more options]
Note 1: If compiled with support for GnuPG, the TIGER192 checksum of the gpg executable will be compiled into samhain, and the gpg executable will be checksummed (to verify its integrity) before invoking it. If you don't like this, you should add the configure option:
--with-checksum=no
Compiling in the GnuPG checksum will tie the samhain executable to the gpg executable. If you upgrade GnuPG, you will need to re-compile samhain. If you don't like this, use '--with-checksum=no'.
Note 2: The mere fact that the signature is correct does not prove that it has been signed by you with your key - it just proves that it has been signed by somebody. Samhain can optionally check the fingerprint of the key / p { margin: 1.4em 0 0.4em 0; } hr { color: transparent; background: transparent; height: 0px; margin: 0.6em 0; border-width: 1px ; border-style: solid; border-color: #999; } /* bulleted lists and definition lists */ ul { margin: 0 1em 0.6em 2em; padding: 0; } li { margin: 0.4em 0 0 0; } dl { margin: 0.6em 1em 0.6em 2em; } dt { color: #285577; } tt { color: #602020; } /* links */ a.link { color: #33c; background: transparent; text-decoration: none; } a:hover { color: #000; background: transparent; } body > a { font-family: Optima, Arial, Helvetica, sans-serif; font-size: 0.81em; } h1, h2, h3, h4, h5, h6 { color: #2d5588; background: transparent; font-family: Optima, Arial, Helvetica, sans-serif; font-weight: normal; } -->
samhain file integrity scanner | online documentation
This document aims to explain how to diagnose and fix common problems that may result from misunderstanding or misconfiguration when setting up a client/server samhain system. This document is divided in several sections more or less corresponding to the different stages when a client connects to a server. Each section starts with a brief explanation that should provide a basic understanding of what is going on.
This document does not discuss how to setup a client/server (for this, look into the manual and/or the HOWTO-client+server).
Connecting to the server
Authentication
Downloading config/database files
Other connection problems
Client/server connections are always initiated from the client. The port is compiled in (there is a configure option to change the default). The default port is 49777.
The client reports: Connection refused. The server reports nothing.
The server is down, listens on the wrong port, or network failure.
The client reports: Connection error: Connection reset by peer, and later also Session key negotiation failed. The server reports: msg="Refused connection from ..." subroutine="libwrap".
The server is compiled with libwrap (TCP Wrapper) support, and the client is either in /etc/hosts.deny, or you have set yule: ALL in /etc/hosts.deny, and forgot to put the client in /etc/hosts.allow.
To fix: make proper entries in /etc/hosts.allow and/or /etc/hosts.deny. There is no need to restart/reload the server.
The client has a password that is used to authenticate to the server. This password is located within the binary, and is set with the samhain_setpwd helper application, as explained e.g. in the manual or in the Client+Server HOWTO.
The server has a list of clients that are allowed to connect, and the verifiers corresponding to the passwords of these clients.
Upon successful authentication, client and server will negotiate a session key that is used for signing further messages from the client.
If the password is wrong, the client will report Session key negotiation failed. The server will report: Invalid connection attempt: Session key mismatch
To fix: make sure that the password has in fact been set, that you are using the correct executable for the client (the one where the password is set), and that the entry in the server config file is the one generated for this password (also look out for double entries for this client).
If the client name (as resolved on the server) is wrong, the client will report Session key negotiation failed. The server will report: Invalid connection attempt: Not in client list, and it will tell you in the same error message what name it has inferred for the connecting client (example): client="client.mydomain.com".
The fix depends on the nature of the problem. In principle, it should be sufficient to change the name of the client in the config file entry, which isn't really a solution if e.g. the server thinks the client is 'localhost'.
There are two different ways to determine the client name. Unfortunately, judging from customer feedback as well from common sense, both do not work very well with a messed up local DNS (including /etc/hosts files) and/or überparanoid or misconfigured firewalls (in case of connections across one).
First method: Determine client name on client, and try to cross-check on server
This does not work for a number of people because (1) the /etc/hosts file on the client machine has errors (yes, there are plenty machines with a completely messed up /etc/hosts file), (2) the server cannot resolve the client address because the local DNS is f***ed up, or (3) the client machine has multiple network interfaces, and the interface used is not the one the client name resolves to.
If the client uses the wrong interface on a multi-interface machine, there is a config file option SetBindAddress=IP address that allows to choose the interface the client will use for outgoing connections.
If you want to download the config file from the server, you should instead use the corresponding command line --bind-address=IP address to select the interface.
If you encounter problems, you may (1) fix your /etc/hosts file(s), (2) fix your local DNS, or (3) switch to the second method.
Errors in name resolving/cross-checking can be avoided by setting a very low severity (lower than the logging threshold), e.g.
SeverityLookup=debug
in the Misc section of the server configuration, if you prefer running unsafe at any speed instead of fixing the problem (you have been warned). Doing so will allow an attacker to pose as the client.