Tested Templates & Toolstested before it ships

● Server & Claude Code

Check sudoers, systemd, and ufw before an agent applies them

✓ ReproducedPython 3 stdlib · sample checked 2026-10-172026-10-17
ai agentssecuritysudo

An agent with a shell can lock you out of a Linux server in one edit: NOPASSWD: ALL, ufw enable with no SSH allow rule, or a Docker port published on every interface. The free checker at the guardrails MCP server runs on your machine. It does not upload the snippet.

What one sample returned

This is the snippet:

[Service]
User=agent
ExecStart=/usr/bin/python3 /opt/agent/run.py
StartLimitIntervalSec=300

agent ALL=(ALL) NOPASSWD: ALL
ufw enable
ports:
  - "8080:80"

The pattern checks in that snippet are four findings. On this server the same snippet also returns systemd-user-missing, because the account agent is not in the password database. ExecStart=/usr/bin/python3 is executable here, so the path is not a finding. The account check depends on the machine.

The four pattern findings are:

  • high passwordless-root — NOPASSWD: ALL is unrestricted root. Scope sudoers to one root-owned wrapper.
  • high ufw-no-ssh — enabling ufw without an OpenSSH or 22/tcp allow drops the SSH session you are using.
  • medium systemd-startlimit-section — StartLimitIntervalSec under [Service] is ignored on systemd 255 and newer. It belongs under [Unit].
  • high docker-ufw-bypass — 8080:80 publishes on 0.0.0.0 and bypasses ufw. Bind 127.0.0.1:8080:80 if the port should stay local.

The same file's --self-test printed mcp-ops-guardrails self-test: OK on 17 October 2026.

Install it locally

curl -fsSLO https://testedtemplates.com/code/mcp-ops-guardrails.py
python3 mcp-ops-guardrails.py --self-test

Claude Code, Cursor, Codex CLI, and Gemini CLI can run it as a stdio MCP server. Point the command at python3 and the downloaded file. There is no pip install and no account. Read the installation instructions, or clone the files with git clone https://testedtemplates.com/code/agent-ops-free.git.

A browser version that also stays on your machine: the lockout paste check. It does not upload the paste. An agent skill that runs --audit-file on the file it is about to write: server-lockout-check. Coding agents install it with npx skills add https://testedtemplates.com. The index is /.well-known/agent-skills/index.json. Codex CLI adds the git repository: codex plugin marketplace add https://testedtemplates.com/code/agent-ops-free.git and codex plugin add server-lockout-check@testedtemplates. Gemini CLI clones that repository, then runs gemini extensions install ./agent-ops-free --consent. The CLI asks you to trust the folder. A shallow install of the git URL fails here.

What a clean result does not prove

The sudoers, sshd, ufw, and start-limit checks are regular expressions. The user, group, and path checks use the password database and the filesystem on the machine where you run the script. It does not parse sudoers, it does not run sshd -t, and it does not apply the change. A clean result means none of those checks matched. It does not mean the unit is safe to install. A path that is missing here may exist on the host that will run the unit. Run the check there. The status=216/GROUP runs, including a Type=simple start that exited 0, are at status=216/GROUP. A missing BindPaths= or ReadWritePaths= is status=226/NAMESPACE. Read the snippet yourself before anything restarts sshd or writes /etc/sudoers.

Two other tools on the same script scan a command for secrets in argv and rewrite a curl that would put a token on the process list. Those stay local for the same reason: do not paste a live key into someone else's server. scan_secret_leak also flags two bounty-trap shapes: a request to dump a system prompt into a public pull request, and a request to open more issues and star a repo. A match is a pattern, not a verdict that the text is an attack.

If you want the check to run even when the model forgets

The MCP tool only helps when the model calls it. The paid kits are the enforcement around that, for people who already run an agent on a server:

Both were built and tested by AI agents. The longer write-ups of the rules and the systemd unit are the sudo guardrails checklist and Claude Code Remote Control as a systemd service.