I'd like to receive an immediate alert every time something reads the contents of my private key on Debian Linux. How can I do that?
I have an RSA private key stored on my server's disk at the following location:
/etc/ssl/private/super-secret.key
It's only readable by root, but I still want to have a log of every time this secret key has been read by a person or a process, and store the context of that read event for alerting and auditing purposes
How can I setup immediate alerting when a very sensitive file has been read from disk?
This can be achieved using the following two tools:
/var/log/audit/audit.log
audit.log
file and send an email alert when appropriatePrereqs
First, install auditd.
Next, install wazuh. If you've never done this before and its only one server, you probably want the "all-in-one" install.
auditd config
To monitor the file
/etc/ssl/private/super-secret.key
, add an auditd rule to watch (-w
) the file for read access (-p r
) -- and give this rule an arbitrary "key" name (-k audit-wazuh-private-key-r
) so we can match against it later.Restart auditd to apply the rules
wazuh config
Add the following lines to your wazuh main config file (
/var/ossec/etc/ossec.conf
) to enable monitoring of the auditd log fileAdd the "key" name of our rule above to the list of auditd keys that wazuh monitors
Add the following lines to your wazuh local rules file (
/var/ossec/etc/rules/local_rules.xml
) to tell wazuh that this event is a level 12 = "high important event" and that it should trigger an email alertRestart wazuh
Now, any attempt to read the contents of the
/etc/ssl/private/super-secret.key
file will send you an email alert.See Also