---
name: "systemd-service-unit-hardening"
description: "Lock down Linux system services using built-in systemd security sandboxing directives."
metadata:
  author: "systemd"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "harden systemd service"
  - "systemd-analyze security"
  - "protectsystem strict systemd"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# systemd Service Unit Hardening & Sandboxing Directives

Hardens Linux services via systemd unit files: configuring ProtectSystem=strict, ProtectHome=true, NoNewPrivileges=true, PrivateTmp=true, CapabilityBoundingSet, PrivateDevices, and checking score with systemd-analyze security.

## When to Invoke
Invoke this skill whenever you need to:
- harden systemd service
- systemd-analyze security
- protectsystem strict systemd

## Execution SOP & Rules
1. Add [Service] hardening directives: ProtectSystem=strict, ProtectHome=true, PrivateTmp=true.
2. Enforce non-root execution: User=appuser, Group=appgroup, NoNewPrivileges=true.
3. Restrict network and capabilities: CapabilityBoundingSet=, RestrictAddressFamilies=AF_INET AF_INET6.
4. Audit configuration security score: systemd-analyze security <service_name> aiming for score < 2.0.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
