Interview Prep/Linux/SSH & Access Hardening

How do you sandbox a systemd service?

AdvancedProductionSSH & Access Hardening
Answer
[Service]
User=api
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=yes
ReadWritePaths=/var/lib/api /var/log/api
PrivateTmp=yes
PrivateDevices=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
SystemCallFilter=@system-service

systemd-analyze security api.service scores the exposure and lists which directives are missing.

All Linux questions Roadmap: Linux

More on SSH & Access Hardening