How to Configure Amazon Q SSH Prevent Delete
You set up an amazon q ssh prevent delete rule by limiting remote shell accounts. You also restrict local agent approval settings before the tool connects to Linux hosts. Many engineering teams let AI coding assistants run local shell commands to check remote servers. When an assistant uses a broad developer key, one bad command can wipe remote files. Giving an AI tool full write permissions on a server creates high risk. How to set up amazon q ssh prevent delete rules Amazon Q runs terminal
SSH Access Management + End-to-End Encryption: the complete guide
Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.
You set up an amazon q ssh prevent delete rule by limiting remote shell accounts. You also restrict local agent approval settings before the tool connects to Linux hosts. Many engineering teams let AI coding assistants run local shell commands to check remote servers. When an assistant uses a broad developer key, one bad command can wipe remote files. Giving an AI tool full write permissions on a server creates high risk.
How to set up amazon q ssh prevent delete rules
Amazon Q runs terminal commands on your machine using your active shell profile. When the agent opens a remote session, it uses your local OpenSSH keys. OpenSSH does not have a simple toggle to block only file deletions. Instead, you must combine operating system permissions with OpenSSH certificate options.
First, create a dedicated Linux user on the remote host for the AI agent. Give this user read-only group permissions on log folders and app directories. Do not put this user in the admin group or allow root privileges. Standard Linux file modes will stop this user from removing protected files.
Second, use OpenSSH user certificates instead of static public keys. An admin signs a public key with a certificate authority key. The resulting certificate holds the key identity, allowed user names, and security options. You can embed a forced command option inside the signed certificate. This option runs a wrapper script whenever the certificate logs in.
The wrapper script reads the command string that the client wants to run. It checks the string for delete tools or destructive file commands. If the script finds a match, it drops the request right away. If the command only reads data, the script lets it run.
What native SSH setups solve and where they fall short
Linux file permissions and OpenSSH certificates solve the basic login problem. Certificates let you set a clear start and end time for user keys. Forced commands help you filter simple, single-line remote calls. Read-only Linux accounts stop an agent from wiping system folders it does not own.
Still, native setups struggle to inspect complex commands in flight. Shell wrapper scripts are easy to trick with nested quotes or encoded text. An AI agent might write a quick Python script that deletes files. A basic string check will miss that hidden action.
SSH Access Management + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Also, a user needs write permissions to fix bugs or restart services. If you lock down the Linux user completely, the agent can only read files. If you grant write rights, the agent can delete anything it owns. Native OpenSSH decides who logs in, not what each command does during a session.
Why local agent prompts are not enough for remote servers
AI coding assistants ask for user approval before they run terminal commands. Developers often trust these prompts during long coding sessions. When a team member approves a long script, they may miss a bad line. Once the script runs over a remote connection, the server accepts every step.
Shared bastions and jump hosts add another problem for security teams. Many engineers and AI tools share the same jump host keys. When a file disappears, standard server logs only show the shared Linux account name. You cannot tell which person or AI prompt ran the delete command. Plus, output from remote servers can leak emails, phone numbers, or card numbers into prompts. Native OpenSSH cannot rewrite matched fields in results before they reach the agent.
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 provides an open-source SSH server with guardrails on the host that uses OpenSSH certificates.
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
Can OpenSSH block delete commands on its own?
No, OpenSSH does not inspect or block specific shell commands by default. You must write a custom wrapper script and call it through key options. You also need strict Linux file permissions on the remote host.
Why do wrapper scripts fail to stop AI agents from deleting files?
Wrapper scripts only check the raw text of the incoming command string. An AI agent can chain commands, use variables, or call a script language. These paths bypass simple text checks and still remove files.
How does Amazon Q log in to remote SSH hosts?
The agent runs commands inside your local terminal using your current user rights. If your local shell has active SSH keys, the agent uses them to log in. It inherits all remote rights tied to those keys.
Related guides
In this post