September 2026

Hardening systemd services without breaking them

systemd ships a lot of sandboxing knobs. A good starting set for a network daemon that only needs its config is NoNewPrivileges, ProtectSystem=strict, ProtectHome, PrivateTmp and PrivateDevices.

Binding to low ports

Instead of running as root, grant CAP_NET_BIND_SERVICE through AmbientCapabilities and drop everything else with CapabilityBoundingSet.

Check the result

systemd-analyze security name.service gives a quick score and lists what is still exposed.