What is DynamicUser= in systemd?
AdvancedProductionSSH & Access Hardening
Answer
DynamicUser=yes allocates a transient UID/GID when the service starts and releases it when it stops, so no permanent account exists to be abused. It implies ProtectSystem=strict, ProtectHome=read-only, PrivateTmp=yes and NoNewPrivileges=yes. Persistent data goes in StateDirectory=api (/var/lib/api), LogsDirectory=, CacheDirectory=, which systemd chowns automatically. Great for stateless helpers and exporters.
More on SSH & Access Hardening
What are the first sshd_config changes you make on a new production server?BeginnerWhy use a drop-in file in /etc/ssh/sshd_config.d/ instead of editing sshd_config?IntermediateWhy disable SSH password authentication entirely?BeginnerShould you change the SSH port from 22?IntermediateWhat are SSH certificates and why do large fleets use them?AdvancedHow do you restrict what a specific SSH key can do?Advanced