monitoring: watch peers, devices, accounts and logins
All checks were successful
deploy / ansible (push) Successful in 8m12s
All checks were successful
deploy / ansible (push) Successful in 8m12s
Monitoring covered availability only: a new WireGuard peer, a machine on the private network, an extra account or key, or a login from outside the VPN would have gone unnoticed. security-metrics runs every minute on both hosts and exports what it finds for node_exporter: WireGuard peers and where they connect from, addresses answering a ping sweep of the VPC, login accounts, sudo and docker members, listening ports, containers with host-level access, and fingerprints of the account, sudoers, sshd, WireGuard and authorized_keys files. Each item is compared with a baseline in the role defaults and host_vars and exported with known="true|false", so a deliberate change has to update the baseline with it. On ops it also counts Forgejo users, keys and runners. Grafana gets a Security dashboard and an alert group for anything unknown, a changed access file, an SSH login from outside WireGuard, failed-login bursts on SSH, Forgejo, Grafana and the asxp.io admin, a new container, and for logs or the collector itself going quiet, which would otherwise blind the rest. It never reads `wg show dump`, which prints preshared keys. Assisted-by: Claude:fable-5-2
This commit is contained in:
parent
1c8eec8520
commit
56dd0255dc
1 changed files with 2961 additions and 1 deletions
53
ansible/roles/monitoring_agent/defaults/main.yaml
Normal file
53
ansible/roles/monitoring_agent/defaults/main.yaml
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
---
|
||||
# Security baseline for security-metrics: what each host is expected to
|
||||
# have. Anything else is exported with known="false" and alerts (rules in
|
||||
# role monitoring). Per-host additions go in host_vars as *_extra.
|
||||
|
||||
# Accounts with a login shell
|
||||
security_login_users: [root, asxpi, deploy, zerrtika]
|
||||
security_login_users_extra: []
|
||||
|
||||
# Members of groups that amount to root
|
||||
security_sudo_users: [asxpi, deploy, zerrtika]
|
||||
security_docker_users: [asxpi, deploy, zerrtika]
|
||||
security_docker_users_extra: []
|
||||
|
||||
# Addresses expected on the private network (.1 is Hetzner's gateway)
|
||||
security_vpc_hosts:
|
||||
- "{{ vpc_network.split('/')[0].rsplit('.', 1)[0] }}.1"
|
||||
- "{{ asxpio_ops_vpc_ip }}"
|
||||
- "{{ asxpio_services_vpc_ip }}"
|
||||
|
||||
# WireGuard peers: by the "### Client <name>" comment in the interface's
|
||||
# conf (the server), or by public key -> name (a client)
|
||||
security_wg_peer_names: []
|
||||
security_wg_peer_keys: {}
|
||||
|
||||
# Listening sockets outside loopback: proto/port/process. port is a number,
|
||||
# a range or *; process is the owner `ss -p` shows (empty for the kernel).
|
||||
security_ports:
|
||||
- tcp/22/sshd
|
||||
- udp/68/dhclient
|
||||
- "tcp/12345/alloy"
|
||||
- "tcp/{{ monitoring_node_exporter_port }}/node_exporter"
|
||||
- "tcp/{{ monitoring_cadvisor_port }}/cadvisor"
|
||||
security_ports_extra: []
|
||||
|
||||
# Containers allowed host-level access: name (regex) -> flags, out of
|
||||
# privileged, host-net, host-pid, host-root, docker-sock, cap-<NAME>
|
||||
security_containers:
|
||||
cadvisor: [privileged, host-net, host-root]
|
||||
node-exporter: [host-net, host-pid, host-root]
|
||||
alloy: [host-net, docker-sock]
|
||||
security_containers_extra: {}
|
||||
|
||||
# Files whose change alerts, by set. authorized_keys files of every
|
||||
# account are always watched (set ssh_keys).
|
||||
security_filesets:
|
||||
accounts: [/etc/passwd, /etc/shadow, /etc/group, /etc/gshadow]
|
||||
sudoers: [/etc/sudoers, "/etc/sudoers.d/*"]
|
||||
sshd: [/etc/ssh/sshd_config, "/etc/ssh/sshd_config.d/*"]
|
||||
wireguard: ["/etc/wireguard/*.conf"]
|
||||
|
||||
# Forgejo's SQLite database, where this host runs Forgejo
|
||||
security_forgejo_db: ""
|
||||
Loading…
Reference in a new issue