systemd Service Sandboxing Hardener

    1

    Most hardening guides paste thirty directives at once; the service crashes, the operator deletes them all, and nothing is learned.

    $29

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    systemd Service Sandboxing Hardener

    Example session with this skill installed

    Our Node API runs as myapp-web.service on an Ubuntu 24.04 VPS with secrets in an EnvironmentFile. Harden it as far as it will go without breaking it, and tell me what you had to allow.

    • Read your context and instructions
    • Compiled the systemd service sandboxing

    Summary

    myapp-web.service went from systemd-analyze security 9.6 UNSAFE to 1.9 OK across three tiers. Two allowances were needed and both are recorded. Secrets moved from the EnvironmentFile to encrypted credentials.

    Before

    $ python3 scripts/audit_unit.py --unit myapp-web.service --profile strict
      baseline   1 / 13
      strict     1 / 12
    FAIL: 23 directive(s) missing for profile 'strict'.
      Secrets  LoadCredentialEncrypted=, not Environment=   missing   EnvironmentFile= /etc/myapp/app.env; secret-shaped names: SESSION_SECRET, STRIPE_API_KEY
    

    Tiers applied

    TierDrop-inResultBrokeAllowance
    baseline10-baseline.conf13/13PDF export wrote to /var/lib/myapp/exportsReadWritePaths=/var/lib/myapp
    strict15-strict.conf + ExecStart=/usr/bin/node --jitless12/12first attempt: SIGSEGV at start (MemoryDenyWriteExecute without --jitless)--jitless; measured +18% CPU on the render endpoint, +2% elsewhere
    locked18-locked.conf7/7nothing; MemoryMax=512M sized from 310 MB observed peaknone

    Secrets

    systemd-creds setup
    printf '%s' "$SESSION_SECRET" | systemd-creds encrypt --name=session_secret - /etc/credstore.encrypted/myapp-web-session
    printf '%s' "$STRIPE_API_KEY" | systemd-creds encrypt --name=stripe_api_key - /etc/credstore.encrypted/myapp-web-stripe
    

    20-encrypted-credentials.conf installed; src/config.mjs now reads $CREDENTIALS_DIRECTORY/session_secret and .../stripe_api_key; EnvironmentFile= removed. systemctl show myapp-web no longer exposes either value.

    After

    $ python3 scripts/audit_unit.py --unit myapp-web.service --profile locked
      baseline  13 / 13   strict  12 / 12   locked  7 / 7
    OK: profile 'locked' satisfied. Confirm with: systemd-analyze security myapp-web.service
    $ systemd-analyze security myapp-web.service | tail -1
    → Overall exposure level for myapp-web.service: 1.9 OK
    

    nginx

    check-nginx-conflicts.sh /etc/nginx found api.example.com:443 declared in both sites-enabled/api.conf and sites-enabled/legacy-api.conf; removed the legacy file, nginx -t clean, reloaded.

    Not done

    No privilege split was needed; the service holds no capability. Re-run journalctl -u myapp-web | grep -i oom after 24 h to confirm MemoryMax headroom.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    A stock unit file runs your service with the whole filesystem, every address family, every syscall and whatever secrets you put in Environment= visible to anything that can read /proc. Most hardening guides paste thirty directives at once; the service crashes, the operator deletes them all, and nothing is learned. This skill applies hardening in three cumulative tiers, verifying the service still does its real work after each one, and gives your agent the two patterns that make strict sandboxing possible for real workloads.

    You get

    • scripts/audit_unit.py (Python, stdlib, offline): audits a unit's effective settings from systemctl show output against a tiered profile (baseline, strict, locked), flags secret-shaped environment variable names without ever printing values, and exits non-zero on gaps. Works offline on captured output.
    • Drop-in templates per tier for a web service, so each tier can be applied and reverted on its own.
    • A complete unprivileged agent unit and a one-capability helper unit (CAP_NET_ADMIN over a peer-credential-checked Unix socket) for the privilege-split pattern.
    • A Node.js unit that keeps MemoryDenyWriteExecute=yes by running node --jitless, with guidance on measuring the cost.
    • An encrypted-credentials drop-in with the exact systemd-creds commands that replace Environment= secrets.
    • sysusers.d and tmpfiles.d files so users and directory modes are reproducible on a fresh host.
    • scripts/check-nginx-conflicts.sh: finds duplicate server_name:port blocks and duplicate rate-limit zones that nginx accepts silently.

    Requires systemd 250+ for encrypted credentials; the audit works on older versions. Not for containerized services.

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for DevOps & Cloud.

    Requires systemd v250+ for full feature set. Auditor detects configuration presence, not binary runtime safety. Templates use Debian/Ubuntu paths. Not for containerized (Docker/Podman) services.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 19 days ago

    Software
    systemd
    Root
    orsudo access
    Python 3.9+Bash

    Root or sudo installs the drop-ins. Python uses only the standard library.

    Permissions

    Network Access
    Listed19 days ago

    What's inside

    Frequently Asked Questions

    This skill is designed for Linux environments running systemd v250 or later. It is optimized for AI agents that have terminal access or those used in automated CI/CD pipelines to manage host-level service configurations.

    Unlike generic security advice, this skill uses a verified three-tier workflow that allows you to incrementally test hardening layers, preventing the 'all-or-nothing' crashes common with basic AI-generated unit files. It also includes specific optimizations for complex runtimes like Node.js and handles advanced privilege-split architectures.

    The package includes the `audit_unit.py` tool for baseline assessments, a library of tiered configuration drop-ins, privilege-split helper templates, and an automated migration workflow for encrypting secrets. You also receive the integration logic needed for your AI agent to apply these tools safely.

    Yes, the Tiered Hardening workflow is designed for incremental deployment. You can apply baseline isolation first to ensure stability before moving to stricter syscall filtering and memory protection, allowing you to catch compatibility issues before they reach production.

    By migrating secrets from environment variables to encrypted systemd credentials, the skill ensures that sensitive data is only accessible to the service at runtime via a secure directory, preventing leaks through process listing or log files.

    New in DevOps & Cloud