-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate-auditdistd-conf
executable file
·52 lines (44 loc) · 1.14 KB
/
generate-auditdistd-conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#! /bin/sh -
set -eu
configdir=./auditdistd-configs
cert="$configdir/auditdistd.cert.pem"
key="$configdir/auditdistd.key.pem"
if [ ! -d "$configdir" ] || [ ! -w "$configdir" ]
then
rm -rf -- "$configdir"
mkdir -p "$configdir"
fi
openssl req -x509 -nodes -newkey rsa:4096 -days 1825 -batch -out "$cert" -keyout "$key"
fingerprint="$(openssl x509 -in "$cert" -noout -fingerprint -sha256 | awk -F '[ =]' '{printf("%s=%s\n", $1, $3)}')"
password="$(dd if=/dev/urandom bs=32 count=1 | openssl base64 | cut -b -32)"
cat > "$configdir/auditdistd-freebsd-receiver.conf" << EOS
receiver {
host "linux-sender" {
remote "tls://192.168.10.12"
password "$password"
}
host "freebsd-sender" {
remote "tls://192.168.10.13"
password "$password"
}
}
EOS
cat > "$configdir/auditdistd-linux-sender.conf" << EOS
sender {
host "freebsd-receiver" {
remote "tls://192.168.10.11"
fingerprint "$fingerprint"
password "$password"
directory "/var/log/audit/auditdistd"
}
}
EOS
cat > "$configdir/auditdistd-freebsd-sender.conf" << EOS
sender {
host "freebsd-receiver" {
remote "tls://192.168.10.11"
fingerprint "$fingerprint"
password "$password"
}
}
EOS