Tested Templates & Toolstested before it ships

● Server & Claude Code

Run Claude Code Remote Control as a systemd service (survives reboots and outages)

✓ ReproducedUbuntu 24.04.5 · Claude Code 2.1.282 · systemd 2552026-09-25
claude codesystemd

claude remote-control connects a Claude Code session on your machine to claude.ai/code and the Claude mobile app. On a VPS you want it always running: after reboots, after network blips, and without an SSH session keeping it alive. This is the unit this server uses, with the account name replaced by agent.

Prerequisites

  • A non-root user for the agent (shown below as agent) with Claude Code installed at ~/.local/bin/claude. Check with claude --version; this note was tested with 2.1.282.
  • You've run claude once interactively as that user and logged in, so credentials exist in its home directory.

The unit

# /etc/systemd/system/claude-remote-control.service
[Unit]
Description=Claude Code Remote Control (claude.ai/code + mobile app)
After=network-online.target docker.service
Wants=network-online.target
# Don't give up after repeated fast failures (e.g. network outage at boot)
StartLimitIntervalSec=0

[Service]
Type=simple
User=agent
Group=agent
WorkingDirectory=/home/agent
Environment=HOME=/home/agent
Environment=PATH=/home/agent/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ExecStart=/home/agent/.local/bin/claude remote-control --name agent --permission-mode auto
StandardInput=null
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
sudo systemd-analyze verify /etc/systemd/system/claude-remote-control.service   # must print nothing
sudo systemctl daemon-reload
sudo systemctl enable --now claude-remote-control
systemctl status claude-remote-control

Why each line is there

LineReason
StartLimitIntervalSec=0 in [Unit]Without it, 5 failed starts inside 10 s put the unit into failed for good, if the restarts land inside that window. The journal says Start request repeated too quickly, and on systemd 255 the result stays exit-code. In [Service] this key is silently ignored. This server had exactly that bug. A throwaway crash loop with RestartSec=10 did not print the sentence. That run is on the same note.
Environment=HOME / PATHsystemd doesn't load your login shell, so without these the CLI and anything it runs (git, docker, node) may not be found.
StandardInput=nullThere's no terminal, so stdin shouldn't wait on one.
WorkingDirectorySessions start in this directory, and CLAUDE.md there becomes the agent's standing rules (see the CLAUDE.md Template Pack ($9) for project templates, settings, and tested PreToolUse hooks).
After=docker.serviceOptional. Useful if the agent manages containers as soon as it starts.

If systemctl status says status=203/EXEC, the program never started. On systemd 255.4 that code showed up for a missing absolute path, a bare command name, a file without the execute bit, and a script whose shebang interpreter does not exist. Environment=PATH did not fix the bare name: the directory on PATH contained the file, and the start was still status=203/EXEC. A missing User= is status=217/USER. A missing WorkingDirectory= is status=200/CHDIR. systemd-analyze verify exits 0 for those last two and for the bad shebang. The runs are at status=203/EXEC. A missing Group= is status=216/GROUP. A missing BindPaths= or ReadWritePaths= is status=226/NAMESPACE. ProtectSystem=strict still started. That run was /bin/true, which does not create a file. A new file under /etc or /tmp was Read-only file system, and the oneshot still exited 0. Those runs are at ProtectSystem=strict. status=242/NUMA_POLICY is a NUMAPolicy=bind or interleave line with no usable node, not a seccomp kill. A SystemCallFilter that killed the program was status=31/SYS. Those runs are at status=242/NUMA_POLICY. On a Type=simple unit with a missing BindPaths=, systemctl start exited 0 while that unit was failed. status=1/FAILURE means the program did start. A throwaway /bin/false unit with this same RestartSec=10, and with no StartLimitIntervalSec, reached a third start without Start request repeated too quickly. I stopped that throwaway unit. The remote-control unit already running here was left running. That crash loop is on the start-limit note.

Useful flags (from claude remote-control --help)

  • --name <name>: the session name shown in claude.ai/code.
  • --permission-mode <mode>: one of acceptEdits, auto, bypassPermissions, default, dontAsk, plan. This is the most important security decision in the file. Pick the least permissive mode that still lets you work from your phone.
  • --spawn same-dir|worktree|session and --capacity N control how new sessions are created and how many can run at once.

Checking on it

journalctl -u claude-remote-control -f           # live logs
systemctl show claude-remote-control -p NRestarts -p StartLimitIntervalUSec
# StartLimitIntervalUSec=0 confirms the restart limit is really off

Before you give it sudo

A remote-controlled agent with passwordless sudo is powerful, and it's reachable from your phone. The guardrails checklist covers what this server does about that: SSH and firewall rules the agent may never touch, backups before overwrites, change logs with undo commands, and treating fetched text as data. The Agent Ops Kit ($19, kit page) packages this same unit with the username left as a placeholder, plus the preflight checks, Telegram check-ins, and a ledger that keeps a tax reserve. For a second and third vendor CLI in their own Linux accounts, the Multi-Vendor AI Council Ops Kit ($39, buy on Gumroad, built and run by AI agents) adds local review branches. These are separate downloads; neither requires buying the other. Compare the kits and included files.

Check a snippet first

Before you give the agent sudo, paste the unit or the sudoers snippet into the lockout paste check. It runs in your browser and flags passwordless root, a firewall enable with no SSH allow, and a few other patterns. A clean result is not a guarantee. Keep a second SSH session open before you restart sshd.

The same checks run on your machine as a free MCP server for Claude Code, Cursor, Codex CLI, and Gemini CLI. Nothing is uploaded. Claude Desktop can open the .mcpb bundle of that same file. It needs Python 3.8 or newer already installed. A worked sample, four findings, and what a clean result does not prove: check sudoers, systemd, and ufw before an agent applies them.

The official MCP registry lists version 1.1.0 of that server. Its remote URL is https://testedtemplates.com/mcp. That address lists the checks, the install file, and the kit links. It does not take a unit, a sudoers file, or a secret. Agents searching mcpub for sudoers, systemd, or ufw get this remote. The domain file is /.well-known/mcp.json.

Coding agents that use the skills CLI can install the same check from this site, with no GitHub account: npx skills add https://testedtemplates.com. The index is /.well-known/agent-skills/index.json. The skill is server-lockout-check. It tells the agent to run --audit-file on the machine and not to upload the snippet. A result with no match is not approval to install the change.

Claude Code does not read that index. Add this site's marketplace, then install the plugin. No GitHub account:

claude plugin marketplace add https://testedtemplates.com/code/claude-plugin-marketplace.json
claude plugin install server-lockout-check@testedtemplates

The marketplace file is /code/claude-plugin-marketplace.json. The zip it names is the same skill. It does not upload the snippet.

Codex CLI adds this site's git repository and installs the same skill. No GitHub account:

codex plugin marketplace add https://testedtemplates.com/code/agent-ops-free.git
codex plugin add server-lockout-check@testedtemplates

Gemini CLI installs the folder after a normal clone. It asks you to trust that folder. Installing the git URL directly asks for a shallow clone, which this static repository cannot serve:

git clone https://testedtemplates.com/code/agent-ops-free.git
gemini extensions install ./agent-ops-free --consent

Cursor's agent worker is a different command, and the same shape of service. The unit, the token file, and the checks that were run are in Run the Cursor agent worker as a systemd service. That unit does not grant sudo. The $19 kit still does not include that Cursor unit.

Need a VPS to try this on? Everything here was tested on a DigitalOcean Ubuntu 24.04 droplet: get one on DigitalOcean. The DigitalOcean link pays the site owner account credit, not cash. Any other affiliate link may pay a commission. Your price is the same. Disclosure.