Blueprints · Systemd & Agents
Production
15 min · systemd
systemd credential file
Stages a pattern that loads a mode 600 file as a credential instead of putting the secret in the unit.
Live config
Baked-in protections
- The secret is not in the unit file
- The credential file is staged with a reminder to chmod 600
- The unit is not enabled
Step 1 · ini
Unit snippet
/root/portgate-blueprints/credential.service
Point LoadCredential at a file root owns.
[Service] LoadCredential=appenv:/etc/portgate/app-env ExecStart=/usr/bin/app NoNewPrivileges=true
Step 2 · text
Env file placeholder
/root/portgate-blueprints/app-env
Replace the contents. chmod 600. Do not commit this file.
TOKEN=change-me
Step 3 · bash
Read-only check
/root/portgate-blueprints/credential-check.sh
Prints the staged file mode. It does not print the file.
#!/bin/sh set -eu if [ -f /root/portgate-blueprints/app-env ]; then stat -c '%a %n' /root/portgate-blueprints/app-env fi