Skip to content
Tutorials Center
My learning

Topics

Lesson 32 of 37 ยท Integration and Operations

Security, Encryption and Permissions

Secure a monitoring system: TLS with PSK or certificates, user roles and host group permissions, secret macros, hardening the frontend, and Nagios security basics.

A monitoring server knows every host, many credentials, and often has permission to run commands everywhere. That makes it an attractive target. Hardening it is part of operating it. This lesson covers encryption between components, user roles and permissions, secrets, frontend and server hardening, and the equivalent for Nagios. The products are not available on this site; configuration is shown as read-only, and stand-ins check policies and permission logic in Python.

What needs protection

  • Data in transit: agents, proxies, server, database and browsers exchange values, commands and passwords.
  • Credentials: SNMP communities, database passwords, API tokens, SSH keys, webhook tokens.
  • Remote execution: Zabbix can run scripts on agents; Nagios plugins run commands; both can become a path to every host.
  • The frontend: a PHP web application reachable by many people.
  • Data at rest: the database holds host inventories and configuration.

TLS between components

Zabbix supports TLS 1.2 and 1.3 using pre-shared keys (PSK) or certificates between server, proxy and agent.

PSK on an agent:

Terminal
# generate a 256-bit key and save it (read-only example)
openssl rand -hex 32 > /etc/zabbix/zabbix_agentd.psk
chmod 640 /etc/zabbix/zabbix_agentd.psk
INI
# zabbix_agentd.conf
TLSConnect=psk
TLSAccept=psk
TLSPSKIdentity=web01-psk
TLSPSKFile=/etc/zabbix/zabbix_agentd.psk

In the frontend, open the host's Encryption tab, choose PSK for connections to and from the host, and paste the identity and the key. They must match exactly. Use a different PSK per host or per group: a single shared key means one stolen agent compromises trust for all.

With certificates, you set TLSCAFile, TLSCertFile, TLSKeyFile and optionally TLSServerCertIssuer and TLSServerCertSubject. Certificates scale better to thousands of hosts with an internal CA, at the cost of managing renewals.

The frontend and database also need TLS: serve the web interface over HTTPS only (redirect HTTP, use HSTS), and enable TLS for the database connection (DBTLSConnect and related options).

Users, roles and permissions

Zabbix permissions have two parts.

Roles decide what a user can do: the user type (User, Admin, Super admin), which frontend sections are visible, which API methods and API access are allowed, which actions are allowed (acknowledge, close problems, execute scripts). Create roles such as "Read-only NOC", "Team operator" and "Automation (API only)".

User groups with host group permissions decide what the user can see: Read, Read-write or Deny per host group, with tag filters in newer versions. The rules to remember:

  • Without a permission entry, a host group is invisible.
  • When a user is in several groups and the rules conflict, Deny wins, otherwise the highest level wins.
  • Nested host groups inherit permissions through the group name (Europe/Berlin is under Europe) if you choose "apply to subgroups".
  • Template permissions work through template groups.

Other measures: switch to SAML or LDAP with just-in-time provisioning, enforce MFA (TOTP or Duo, available in 7.0), set password policy and session timeout, and disable the default Admin / zabbix credentials on day one. Remove the guest user's access unless you want a public dashboard.

Secrets

  • Use secret text macros ({$DB.PASSWORD} with type "Secret text") so values are hidden in the frontend and API.
  • Use Vault macros (HashiCorp Vault or CyberArk) for passwords that should never be stored in the database.
  • Keep passwords out of zabbix_server.conf readable files: restrict file mode to the zabbix user.
  • For SNMPv3, prefer authPriv with SHA and AES over v2c communities.

Hardening checklist

  1. Run server, proxy and agent as the unprivileged zabbix user.
  2. Agent: set Server= to exact addresses, not a wide range; keep AllowKey and DenyKey lists tight, and leave system.run disabled (DenyKey=system.run[*] or EnableRemoteCommands=0 in old versions).
  3. Firewall: expose 10050 and 10051 only to the necessary peers, the frontend only to the right networks.
  4. Keep the system patched; subscribe to the vendor's security advisories.
  5. PHP: hide the version (expose_php=Off), set secure cookies, put the frontend behind a reverse proxy with rate limiting.
  6. Review the Audit log (Reports > Audit log) for logins, changes and deletes. Ship it to a central log system.
  7. Back up regularly and test the restore (see backup and troubleshooting).
  8. Limit scripts (Alerts > Scripts) by user role and host group; scripts running as root through the agent are especially risky.

Nagios security

  • Protect the web interface with HTTP authentication or a modern front end behind SSO, and set use_authentication=1 in cgi.cfg. Grant authorized_for_* rights narrowly.
  • Keep the external command file writable only by the Nagios group.
  • NRPE: fixed commands, allowed_hosts, TLS (see Nagios distributed monitoring). Never enable argument passing without strong reasons.
  • Plugins run as the nagios user; file permissions on the plugins directory matter.
  • Sanitize macros that come from remote systems ($SERVICEOUTPUT$) before using them in shell commands, or output from a compromised host can inject commands.

Stand-in: permission resolver

This stand-in implements the host group rule in Zabbix (deny beats allow, highest wins, hidden by default).

Python Host group permission resolution (Python stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Stand-in: config policy checker

Audit settings in a script rather than by memory. This checks an agent configuration text against a short policy.

Python Agent config policy check (Python stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. When two user groups give conflicting permissions on a host group, what applies?

    An explicit Deny overrides other permissions.
  2. 2. Why use a different PSK per host or group?

    Separate keys limit the blast radius of a compromise.
  3. 3. What is a good way to store an API token in a Zabbix macro?

    Secret macros are masked; Vault macros are not stored in the database.
  4. 4. Which Nagios NRPE practice is the safest?

    Fixed commands and address restrictions limit what a caller can execute.

Summary

  • Encrypt agent, proxy and server traffic with PSK or certificates; serve the frontend over HTTPS.
  • Roles control actions; host group permissions control visibility, and Deny wins.
  • Keep secrets in secret or Vault macros, disable remote commands unless needed, and review the audit log.
  • Nagios needs authenticated CGIs, a protected command file and careful macro use.

Next: Backup, Upgrade and Troubleshooting