How to Configure Claude Code SSH Sandbox
You set up a claude code ssh sandbox by restricting the agent to an isolated host user. You also pair manual shell approvals with signed OpenSSH certificates. Teams often let AI coding agents use a developer's personal SSH keys to reach remote servers. When permissions are too broad, a bad command from the agent can alter live server files. It can also read sensitive data like emails or card numbers stored on the host. How to set up a claude code ssh sandbox Claude Code reaches external syste
Claude Code Security + SSH Access Management: the complete guide
Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.
You set up a claude code ssh sandbox by restricting the agent to an isolated host user. You also pair manual shell approvals with signed OpenSSH certificates. Teams often let AI coding agents use a developer's personal SSH keys to reach remote servers. When permissions are too broad, a bad command from the agent can alter live server files. It can also read sensitive data like emails or card numbers stored on the host.
How to set up a claude code ssh sandbox
Claude Code reaches external systems through Model Context Protocol servers and its built-in Bash tool. In Manual mode, the Bash tool asks for human approval before running most shell commands. Only a small built-in list of read-only local commands runs without a prompt. Still, once you approve an SSH command, the remote server takes over permission checks.
To build a safe remote sandbox, start by creating a dedicated Linux user on the target host. Give this user read-only rights to logs and app folders, and block sudo rights. Do not copy static private keys to the developer machine for the agent to use.
Instead, use OpenSSH certificate login, which arrived in OpenSSH 5.4. An admin uses the keygen tool and a Certification Authority key to sign a user certificate. This certificate holds a public key, an identity string, principal names, and a validity window. The target host checks the authority signature and matches the principal name to the sandbox user. When the time window ends, the certificate expires on its own.
What native SSH controls solve and what they miss
Native OpenSSH certificates and restricted Linux users solve the initial login problem well. They stop the AI agent from logging in as root or using permanent keys. If a certificate leaks, its short time window limits the risk to a brief period. The dedicated Linux user also stops the agent from changing system files outside its folder.
Yet this native setup leaves a major operational gap during an active session. Host login controls only decide who can log in to the machine. They do not inspect what individual commands do once the session starts. If a user approves a remote shell call, the agent can run many commands inside that one command string.
Claude Code Security + SSH Access Management: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Standard SSH setups also cannot rewrite sensitive text inside command output on the fly. If a remote log file contains customer phone numbers or national IDs, the raw text returns to the agent. Native host logs also struggle to tie every remote shell command back to a specific AI prompt. Teams need a way to check each command and mask sensitive output in flight.
Managing manual approvals and MCP servers
Some teams use Model Context Protocol servers instead of raw Bash commands for remote tasks. MCP servers let Claude Code talk to external tools, databases, and APIs through structured calls. The official docs urge teams to verify they trust each MCP server before use. They also suggest using read-only accounts so queries cannot change data.
When you use MCP for SSH tasks, the server still needs credentials to reach the remote host. Storing long-lived SSH keys inside an MCP config file brings back the same security risks. If the agent runs a broad script through the server, host user limits still apply. Combining strict local approvals with short-lived host credentials gives you a stronger baseline.
Inspect one-shot SSH commands and file tasks
SSH certificates and host rules decide who is allowed on a machine. Setup alone does not check single commands or block sftp reads on sensitive paths. By design, hoop.dev runs an inline open-source SSH listener on the host where engineers and AI agents keep their normal ssh, sftp, and scp tools. On every production command or file operation, hoop.dev decides whether to pass, mask, block, or hold it for approval.
First, hoop.dev guardrails check one-shot commands and file paths before they run, and hoop.dev data masking masks matched values in file downloads. The audit trail logs the certificate principal, requested action, and verdict without storing session content. Interactive shells carry no guardrails and can be turned off when every action must be checked. Explore the code on GitHub.
Frequently asked questions
How does Claude Code run SSH commands on a remote host?
Claude Code runs SSH commands through its Bash tool or through an MCP server. In Manual mode, the Bash tool asks for your approval before opening the remote session.
Why use OpenSSH certificates instead of static keys for an AI sandbox?
OpenSSH certificates include a signed identity, allowed principal names, and a set expiration time. This stops the agent from using permanent private keys that never expire.
Can a restricted Linux user stop sensitive data from reaching the AI model?
No, file permissions only control which files the sandbox user can open and read. If an allowed log file holds emails or card numbers, native SSH sends that raw text back.
Related guides
In this post