How to Configure Claude Code SSH Data Masking

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up claude code ssh data masking by filtering shell output before the agent reads it. Native SSH and Claude Code do not mask sensitive text on their own. Most teams let the agent run remote commands with standard user keys. When those permissions are too broad, the agent reads raw logs and files. Those files often hold real customer emails, phone numbers, and card numbers. That raw text flows right into the model context window. How native permissions work for claude code ssh data maski

Claude Code Security + Data Masking (Static): 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 data masking by filtering shell output before the agent reads it. Native SSH and Claude Code do not mask sensitive text on their own. Most teams let the agent run remote commands with standard user keys. When those permissions are too broad, the agent reads raw logs and files. Those files often hold real customer emails, phone numbers, and card numbers. That raw text flows right into the model context window.

How native permissions work for claude code ssh data masking

Claude Code reaches remote systems in two main ways. First, it uses the Model Context Protocol to talk to external tools and APIs. Second, it runs shell commands through its built-in Bash tool. In Manual mode, the Bash tool asks for human approval before running most commands. It only skips approval for a small list of safe, read-only commands.

When the agent runs an SSH command, it uses the local system setup. OpenSSH uses keys or certificates to check who is logging in. A certificate holds a public key, an identity, and a list of allowed user names. A Certificate Authority key signs this data so the remote host trusts it. OpenSSH added this certificate method in version 5.4 to simplify key management.

Admins can also set options inside the OpenSSH certificate. They can limit which commands a user key can run on the host. Some teams also build custom wrapper scripts on the target server. These scripts try to scrub emails or national IDs using text matching rules. The script runs the command, rewrites matched fields in results, and prints the output.

What native SSH controls solve and what they miss

Native OpenSSH certificates and agent approval modes solve the login problem well. They decide who can log in to a host and start a session. Manual mode in Claude Code also stops the agent from running surprise shell commands. A human can review the command text before the agent sends it out.

Still, login checks do not inspect what happens inside the active session. Once OpenSSH lets the user in, the shell sends back whatever text the command finds. Even a read-only command on a production log file returns raw text. If that log holds customer phone numbers or card numbers, the terminal prints them. Claude Code then reads that terminal output and sends it to the model.

Claude Code Security + Data Masking (Static): architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Homegrown scrubbing scripts on remote hosts are also hard to maintain. Engineers must copy those scripts to every single server in the fleet. If a developer runs a new command flag, the script might miss the output. Also, local keys sit on the developer laptop where any local process can use them. Native SSH simply lacks a built-in way to rewrite sensitive fields in flight.

Planning a safer workflow for remote agent commands

To protect data during agent sessions, teams need controls that work on the output stream. Start by listing which remote hosts the coding agent actually needs to reach. Limit the agent to read-only roles on those hosts whenever possible. Next, identify the sensitive patterns that appear in your app logs and configs. Common patterns include emails, phone numbers, credit card numbers, and national IDs.

Instead of trusting raw shell output, route agent traffic through a central inspection point. This setup checks every command and rewrites matched fields in results before they return. It also removes the need to store raw SSH keys on the developer machine. You get clear logs of every command the agent runs across your hosts.

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 mask SSH output by default?

No, Claude Code reads the exact text that the Bash tool returns. If an SSH command prints emails or card numbers, the agent sends them to the model.

Can OpenSSH certificates hide sensitive data in terminal output?

No, OpenSSH certificates only handle user and host login checks. They can restrict which command runs, but they do not alter the text that returns.

What types of data should teams mask in SSH sessions?

Teams should rewrite structured fields like emails, phone numbers, card numbers, and national IDs. Masking these fields in results keeps raw secrets out of the model prompt.

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.