How to Configure Mastra SSH Read Only Access
You set up mastra ssh read only access by pairing restricted Linux accounts with OpenSSH certificates. Then you point the agent tool to that limited host account. Teams often give an AI agent a broad server key to speed up testing. When roles are too broad, a bad prompt can delete files or change settings. A safe setup limits what the agent can run on the remote host. How native mastra ssh read only access works A Mastra agent runs tools that open remote shell sessions to check server state.
Auditor Read-Only Access + SSH Access Management: the complete guide
Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.
You set up mastra ssh read only access by pairing restricted Linux accounts with OpenSSH certificates. Then you point the agent tool to that limited host account. Teams often give an AI agent a broad server key to speed up testing. When roles are too broad, a bad prompt can delete files or change settings. A safe setup limits what the agent can run on the remote host.
How native mastra ssh read only access works
A Mastra agent runs tools that open remote shell sessions to check server state. SSH itself does not have a single switch for a read-only mode. Instead, the remote Linux host controls what the logged-in user can do. You start by creating a dedicated OS user with no write rights on key folders. That user can read log files and check running tasks, but cannot edit system files.
Next, you manage how the agent logs in to that account. Static keys sit on disk and are hard to rotate across many servers. OpenSSH certificates offer a cleaner way to handle user keys. A certificate authority key signs a public key to make a user certificate. The certificate holds the public key, identity info, principal names, and signed options. OpenSSH certificates use a much simpler format than X.509 certificates. When you sign a key, you set an identity and list allowed user principals. You also set a time window so the certificate expires on schedule.
You can also add options to the certificate or the authorized keys file. For example, a forced command rule runs one fixed script whenever the key logs in. It ignores whatever shell command the Mastra agent asked to run. This works well when the agent only needs one specific status check.
Where native SSH restrictions fall short for AI agents
Host accounts and OpenSSH certificates solve the login problem well. They check who logs in and which OS user starts the shell session. Still, they do not inspect individual commands while the session runs in flight. Once an agent gets a standard shell, it can run any command allowed for that user.
Auditor Read-Only Access + SSH Access Management: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
A forced command locks the agent to a single action. Yet a Mastra agent often needs to run varied check commands during a task. If you allow a general shell, the agent might read files that hold secrets. Standard SSH logs also record login events, not the full text of every command output. Even a read-only user can read sensitive data from logs or config files. If a log holds emails, phone numbers, card numbers, or national IDs, the agent reads them. Data masking is needed to rewrite matched fields in results before the agent processes them.
Controlling agent commands and data in flight
To keep server checks safe, teams need controls at the command level. Every command from the Mastra tool should be checked before the host runs it. You can allow safe check commands while blocking commands that change state or read secrets. You also want full logs of every command the agent sends and the output it gets. Adding approval steps for risky commands gives engineers final say over agent actions. Rewriting sensitive fields in command output keeps private data out of model prompts.
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 open-source SSH listener on the host where people and agents keep their normal ssh, sftp, and scp tools.
First, hoop.dev guardrails check one-shot commands and file paths before they run. Next, 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
Can OpenSSH enforce read-only commands by itself?
No, OpenSSH only handles the login and starts the remote shell or forced command. The remote operating system permissions decide which files the user can read or write.
Why use OpenSSH certificates instead of static SSH keys for Mastra?
Static keys do not expire on their own and are easy to leak. OpenSSH certificates let you sign a user key with a clear identity and expiration time.
How do you stop a read-only SSH user from sending sensitive data to an LLM?
File permissions can block access to secret folders, but logs often mix safe and private data. Use data masking to rewrite emails, phone numbers, and card numbers in command outputs.
Related guides
In this post