How to Configure Gemini CLI SSH Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up gemini cli ssh read only access, create a restricted Linux user. Then bind that account to a dedicated SSH key or certificate. Engineering teams often connect command-line AI tools to remote servers to check logs. Still, most engineers run the tool with their personal SSH keys. When those keys have broad sudo rights, the AI assistant inherits full control. A bad prompt or model mistake can delete files or restart live services. Setting up gemini cli ssh read only access with native t

Auditor Read-Only Access + 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.

To set up gemini cli ssh read only access, create a restricted Linux user. Then bind that account to a dedicated SSH key or certificate. Engineering teams often connect command-line AI tools to remote servers to check logs. Still, most engineers run the tool with their personal SSH keys. When those keys have broad sudo rights, the AI assistant inherits full control. A bad prompt or model mistake can delete files or restart live services.

Setting up gemini cli ssh read only access with native tools

The Gemini CLI runs shell commands on the local machine when investigating issues. When you ask it to check a remote host, it invokes the local SSH client. That client reads your local key files to log in to the remote server. Because SSH opens a full shell, it has no built-in read-only toggle. Instead, you must restrict what the remote Linux account can do after login.

First, create a dedicated Linux user on the target host with no write permissions. Give this user group read rights to log folders and app states. Do not add this user to sudoers or admin groups. Next, generate a separate SSH key pair just for the AI tool. Place the public key in the authorized keys file for that read-only Linux user.

Teams can also use OpenSSH certificates instead of static public keys. A certificate authority signs a public key with an identity and user principal names. Certificate support arrived in OpenSSH 5.4 and uses a simpler format than X.509. You can embed options in the certificate to limit what the session allows. You can also bind a key to a forced wrapper script on the host. When the AI logs in, the server runs that script and blocks other commands.

What native SSH limits solve and what they miss

A dedicated Linux user stops the AI from editing system files or stopping services. OpenSSH certificates let you set a time window so keys do not last forever. Forced wrapper scripts help restrict the session to a small list of safe commands. These native steps give your team a solid base for safer server checks.

Still, native OS accounts and SSH keys only control who logs in. They do not inspect individual shell commands while the session is running. Maintaining wrapper scripts across hundreds of servers takes a lot of manual effort. If you allow a log tool that has a write flag, the user can still change data.

Auditor Read-Only Access + SSH Access Management: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Native read-only users also cannot hide sensitive data inside the files they read. When the AI reads an app log, the output goes right back to the model. That raw log text often holds emails, phone numbers, card numbers, or national IDs. Without command checks and data masking in flight, sensitive details leave the server.

Why local prompt approvals are not enough for live hosts

Terminal AI tools ask the user for approval before they run a shell command. This step helps catch obvious errors during local coding tasks. Yet human reviewers get tired when checking dozens of long shell commands in a row. A single command can chain several actions together inside one SSH call. One misread flag in a complex pipeline can cause an outage on a live host.

Local approvals also leave no central audit log for security teams to review. If the AI runs a command over SSH, the log lives on the laptop. Server logs only show that the shared read-only account logged in from an IP address. You cannot see which engineer ran the prompt or what output came back. You also cannot ask a teammate to approve a risky command from their chat app.

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 OpenSSH have a built-in read-only mode for shell sessions?

No, OpenSSH only handles the login and opens the shell for the remote user. To limit actions to read-only, you must restrict the Linux user permissions or use forced commands.

How can I stop Gemini CLI from using my personal admin SSH key?

Create a separate SSH host alias in your local SSH config file. Point that alias to a key pair tied to a restricted user on the remote host.

Why do read-only Linux accounts still pose a data risk with AI tools?

A read-only user can still read production logs and config files. Those files often contain secrets, emails, phone numbers, or card numbers that get sent to the AI model.

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.