四款智能體的 SSH 審批方式各異,作者主張以外置沙盒隔離權限
The first step toward letting AI drop your production database
作者比較 Claude Code 2.1.312、Codex CLI 0.170.0、Gemini CLI 0.67.0 和 Grok Build 1.0.45 的 SSH 審批方式,指出批准範圍可能超出 staging 命令。
When you ask an agent to do something over SSH, like checking logs, the harness may ask you for permission to run the command. I wanted to show you how easy it is to accidentally give your agent unattended access to production, and how different agent harnesses handle that approval.
Claude Code
Claude Code 2.1.312 offers these choices when you ask it to run healthcheck.py on staging over SSH:
ssh staging.example /bin/sh -c "python3 healthcheck.py"
1. Yes
2. Yes, and don’t ask again for: ssh *
3. Yes, and switch to auto mode · auto mode handles these prompts for you
4. No
The command named staging.example. The rule Claude offered to save was ssh *. That also matches an SSH command to production.
If your agent can use your production SSH key, choosing “don’t ask again” means it can now SSH into prod without asking you. A confused agent could drop the wrong database. A prompt-injected agent could leak customer data.
Codex CLI
Codex CLI 0.170.0 offers these choices when the same command needs approval to run outside the sandbox:
ssh staging.example /bin/sh -c "python3 healthcheck.py"
1. Yes, proceed (y)
2. Yes, and don't ask again for commands that start with
`ssh staging.example /bin/sh -c 'python3 healthcheck.py'` (p)
3. No, and tell Codex what to do differently (esc)
Codex matches the start of the command. Changing healthcheck.py to diskcheck.py breaks the match. Adding --verbose after the closing quote still matches. If someone edits the script on staging and keeps its name, the rule still applies.
If you approve node as the prefix, the agent gets to pick the script. Both node report.js and node other.js match that rule.
Gemini CLI
Here’s the menu for the same command in a trusted project in Gemini CLI 0.67.0. The future-sessions option only appears if you enable permanent approvals.
ssh staging.example /bin/sh -c "python3 healthcheck.py"
Allow once
Allow for this session
Allow this command for all future sessions
No, suggest changes (esc)
Gemini remembers ssh. “Allow for this session” covers other SSH commands in the same session, including a connection to production. “Allow this command for all future sessions” saves the same rule for later.
Grok Build
Grok Build 1.0.45 offers two ways to stop seeing prompts. Read the first two lines together:
ssh staging.example /bin/sh -c "python3 healthcheck.py"
Always allow: ssh staging.example /bin/sh -c "python3 healthcheck.py"
Yes, and don't ask again for anything (always-approve mode)
Yes, proceed
No, and tell Grok what to do differently
Never allow: ssh staging.example
The first choice remembers this exact health check in this worktree. Change the host or the script and it won’t match. The second choice says “anything” because it switches Grok into always-approve mode. That applies to other tools too. If I only wanted staging checked once, I’d pick the third line.
Claude and Codex terminal transcripts, Gemini and Grok rule definitions, and test notes
Why I use an external sandbox
Every harness handles SSH approvals differently. If you switch providers every month because another model is better or cheaper, it’s easy to make a mistake. You remember that “don’t ask again” covered one staging command in Codex and pick it in Claude out of habit. Now you’ve approved ssh *.
That’s why I want the sandbox outside the harness. I can switch agents and keep the same rules about which files they can read and where they can connect. You don’t need a YC-backed startup to resell you compute at a premium for that. I built co:op to run on the machine you already own. It’s free, it works with all four agents, and its default filtered sandbox keeps your SSH keys outside the container and blocks SSH connections.
來源:DEV Community · dev.to