How to Configure Amazon Q SSH Least Privilege

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up amazon q ssh least privilege, give the agent a restricted Linux user. Pair that user with short-lived OpenSSH certificates and strict command rules. Many teams start by letting the AI coding agent use a developer key. That key often has root rights across many hosts. When a prompt goes wrong, broad permissions let the agent break live servers. How amazon q ssh least privilege works in practice Amazon Q Developer runs local shell commands on a machine to help with tasks. When it open

Least Privilege Principle + 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 amazon q ssh least privilege, give the agent a restricted Linux user. Pair that user with short-lived OpenSSH certificates and strict command rules. Many teams start by letting the AI coding agent use a developer key. That key often has root rights across many hosts. When a prompt goes wrong, broad permissions let the agent break live servers.

How amazon q ssh least privilege works in practice

Amazon Q Developer runs local shell commands on a machine to help with tasks. When it opens a remote shell, it uses the local SSH client and keys. If the local user has admin rights, the agent gets those same rights. You can limit this risk by building a dedicated path for the agent.

Start by creating a separate Linux user on the remote host just for the agent. Do not put this user in the sudo group. Give it read rights only to the log files and folders it needs. Next, switch from static public keys to OpenSSH user certificates. OpenSSH added certificate support in version 5.4 using a simple format.

A certificate authority key signs the user public key to make a certificate. This signed file holds the key, an identity string, allowed user names, and options. You can set a short time window so the certificate expires in minutes. When the time runs out, the agent can no longer log in. You can also bake command limits right into the signed certificate or authorized keys file. This forces the remote host to run only one safe script per login.

What native SSH setup solves and what it misses

Dedicated Linux users and OpenSSH certificates stop static key leaks. They also block the agent from running admin commands with sudo. If someone steals a key file, the short time limit keeps the risk small. This native setup controls who logs into the server and when they enter.

Still, host users and certificates leave a big gap during live sessions. Once a shell opens, OpenSSH does not check each command in flight. If the agent has bash access, it can chain commands or read secret files. Static command rules in OpenSSH are also rigid for fixing work. Locking a key to one script stops the agent from checking other logs. Leaving the shell open lets the agent read customer emails or phone numbers.

Least Privilege Principle + SSH Access Management: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Why teams separate agent logins from human keys

When an AI agent shares a human key, server logs show one name. Security teams cannot tell if a person or the agent ran a command. Giving the agent its own certificate identity fixes this log problem right away. Every login in the system log shows the exact key identity string.

Teams also split dev and prod hosts into different certificate authorities. The agent might hold a valid certificate for a test server. That same file will fail if the agent tries to reach a prod host. You should also turn off agent forwarding and port forwarding in the certificate options. This stops the agent from hopping from one server to another host.

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

Why should Amazon Q not use my personal SSH key?

Your personal key likely has sudo rights and access to many servers. If the agent misreads a prompt, it can delete files or change settings. A separate key limits what the agent can touch and makes logs clear.

How do OpenSSH certificates help with least privilege?

A certificate authority signs a public key with an identity, user names, and options. You can set the certificate to expire after a short window. This removes the danger of forgotten static keys sitting on a laptop.

Can native OpenSSH block specific shell flags inside an open session?

No, OpenSSH checks keys and rules only when the session starts. Once it hands over an interactive shell, the Linux kernel runs the commands. Native SSH cannot pause a single command for human approval mid-session.

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.