How to Configure Claude Code SSH Permissions

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up claude code ssh permissions by combining local Bash prompts with OpenSSH certificates. You also restrict which Model Context Protocol servers the agent can reach. Many teams give their coding agent the developer's own SSH keys on their laptop. This setup lets the agent log in to any server the developer can reach. If the agent runs a bad command, broad keys let it change live hosts. How claude code ssh permissions work in practice Claude Code reaches outside systems in two main way

Claude Code Security + SSH Access Management: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

You set up claude code ssh permissions by combining local Bash prompts with OpenSSH certificates. You also restrict which Model Context Protocol servers the agent can reach. Many teams give their coding agent the developer's own SSH keys on their laptop. This setup lets the agent log in to any server the developer can reach. If the agent runs a bad command, broad keys let it change live hosts.

How claude code ssh permissions work in practice

Claude Code reaches outside systems in two main ways. First, it runs shell commands on your machine through its built-in Bash tool. Second, it talks to outside tools, databases, and APIs through Model Context Protocol servers. When the agent needs to check a remote host, it calls the SSH client. In manual mode, the Bash tool asks for your approval before it runs SSH. The tool only skips approval for basic local read commands like listing files.

Once you approve the local command, OpenSSH handles the login on the remote host. Instead of static keys, teams can sign public keys with a Certificate Authority key. This process creates an OpenSSH user certificate. An OpenSSH certificate holds a public key, identity info, principal names, and signed options. OpenSSH added this simpler certificate format in version 5.4. You can set a validity window so the certificate expires after a short time. If you skip the window, the certificate stays valid forever. You can also bake command rules and source address checks into the signed certificate.

What native SSH controls solve and what they miss

OpenSSH certificates and local Bash prompts solve two different parts of the login flow. The local prompt stops the agent from starting an SSH session without your knowledge. The user certificate proves the identity to the remote host without scattered static keys. Together, they control who can log in and when that login key expires.

Yet this native setup leaves a major gap during the live session. The local prompt only sees the initial SSH command on your laptop. Once the session starts, or if a script passes several remote commands together, visibility drops. OpenSSH checks the user certificate at login time, not for each command inside a shell. You can lock a certificate to one forced command, which breaks interactive debugging. If you leave the shell open for the agent, it gets full OS user rights.

Remote logs also hold sensitive data like emails, phone numbers, card numbers, and national IDs. Standard SSH pipes send all of that raw text straight into the model context. Native SSH keys cannot rewrite matched fields in results before the agent reads them. They also cannot pause a single risky remote command for a second human check.

Claude Code Security + SSH Access Management: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

How to tighten agent sessions on remote hosts

Start by separating the agent's SSH identity from the developer's daily admin key. Create a dedicated OS user on the remote host with read-only group rights. Sign an OpenSSH user certificate that lists only that restricted principal name. Always set a short validity window when you sign the key. Keep the agent in manual mode so it must ask before calling SSH.

If you use an MCP server to run remote tasks, check it carefully first. Vendor docs warn you to verify that you trust each server before using it. Give that server a read-only user account so its actions cannot alter live data. Even with these host rules, teams still need controls over live commands and output.

Add command and file guardrails to SSH access

Host firewalls and certificate principals control who opens an SSH session. Yet an allowed user or agent can still run a bad one-shot command or pull sensitive files over sftp. In practice, hoop.dev sits inline on the host as an open-source SSH server with guardrails that uses OpenSSH certificates. For every one-shot command or sftp task an agent or human runs in production, hoop.dev decides to pass, mask, block, or escalate it for review.

Using hoop.dev SSH controls, guardrails check one-shot commands, env variable names, and sftp or scp paths before they run. Port forwards default to deny unless the target is listed. Because interactive shells have no statement boundary and carry no guardrails, teams can turn them off so every command is checked and logged. Check out the MIT-licensed project on GitHub.

Frequently asked questions

Does Claude Code ask for approval before it runs an SSH command?

Yes, in manual mode the Bash tool asks for approval before running SSH commands. It only skips prompts for a small built-in list of safe local read commands.

Should the coding agent use my personal SSH private key?

No, sharing your personal key gives the agent your full admin rights on every host. Issue a separate OpenSSH user certificate with a restricted principal and a short validity window.

Can OpenSSH certificates hide sensitive data in command output?

No, OpenSSH certificates only handle host and user login checks and basic session options. They do not inspect command output or mask emails, phone numbers, or card numbers.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.