How to Configure Codex SSH Prevent Delete
To set up codex ssh prevent delete rules, restrict host user rights and SSH keys. You can also wrap the shell to block file removal commands before they run. Many teams give AI coding agents a standard SSH key to fix server bugs. When that key maps to a broad Linux account, the agent can delete files. A wrong prompt or bad script can wipe out logs or app code fast. How codex ssh prevent delete works on Linux hosts An AI coding agent reaches remote servers by running shell tools on your machin
SSH Access Management + End-to-End Encryption: the complete guide
Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.
To set up codex ssh prevent delete rules, restrict host user rights and SSH keys. You can also wrap the shell to block file removal commands before they run. Many teams give AI coding agents a standard SSH key to fix server bugs. When that key maps to a broad Linux account, the agent can delete files. A wrong prompt or bad script can wipe out logs or app code fast.
How codex ssh prevent delete works on Linux hosts
An AI coding agent reaches remote servers by running shell tools on your machine. It uses your local SSH client and keys to log in to the host. Once the session starts, the remote operating system controls what the agent can do. OpenSSH does not have a built-in toggle that blocks only delete commands. Instead, you must build this guard using Linux accounts, file modes, and OpenSSH certificates.
First, create a dedicated Linux user on the remote host for the coding agent. Do not let this user run root commands or share an admin group. Give the account read rights on log folders and app files. Remove write rights on parent folders so the user cannot unlink or drop files. On Linux, deleting a file changes the folder, so folder write rights control removal.
Next, use OpenSSH user certificates instead of static public keys. A certificate authority key signs the user key and adds identity names and options. You can embed a forced command option inside the certificate when you sign it. When the agent logs in, the SSH daemon runs that wrapper script first. The wrapper reads the incoming command string before passing it to the shell. If the string contains a remove or unlink call, the script stops the run.
What native SSH setups solve and where they fall short
Linux file modes and OpenSSH certificates solve the basic login problem well. Certificates stop keys from living forever on laptops and let you name allowed principals. Folder permissions stop a basic user account from wiping system paths by mistake. These native controls decide which user logs in and which folders they can touch.
SSH Access Management + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Still, this setup leaves a wide gap during daily work. Agents often need write rights in a folder to update a config or temp file. In Linux, folder write rights also grant the power to delete files there. You can add the sticky bit to a shared folder to limit file removal. Yet the agent can still delete any file that its own Linux user owns. Plus, simple wrapper scripts are easy to bypass when agents run complex shell scripts. An agent might call Python or Perl to unlink a file without using rm. Native SSH rules check the login, not what each command does in flight.
Teams also struggle with secret storage and audit logs across many hosts. The coding agent still needs a private key on disk to start the session. Standard SSH logs show who logged in, not the exact output of every command. When sensitive data like emails or card numbers prints to the screen, nothing rewrites it. Masking tools must rewrite matched fields in results so raw PII stays off client logs.
Check SSH commands and file transfers on the host
OpenSSH keys and certificates decide who can log into a Linux host. They do not check what a one-shot command or file transfer does once the session starts. With hoop.dev, you run an open-source SSH server with guardrails inline on the host. On every one-shot command or file transfer an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.
When a caller runs a one-shot command or moves a file, hoop.dev guardrails check the command or path before it runs, and hoop.dev data masking masks matched sensitive patterns in downloads and output. Interactive shells carry no guardrails because keystrokes have no statement boundary. Teams can turn interactive shells off and allow only commands and file tasks. The audit trail logs who connected and what was allowed or refused, without storing keystrokes or file bytes. See the source on GitHub.
Frequently asked questions
Can OpenSSH block only the rm command by itself?
No, OpenSSH cannot parse shell syntax to block one command on its own. You must pair an OpenSSH forced command option with a custom wrapper script. That script inspects the command string and blocks calls that try to remove files.
Why can an agent still delete files when file permissions are read-only?
In Linux, file deletion depends on the parent folder permissions, not the file itself. If the agent user has write rights on the folder, it can remove files. To stop deletion, remove write permissions on the folder or set the sticky bit.
How do we let an AI agent edit files without allowing file deletion?
Give the agent write rights on the specific file, not on the parent folder. When the folder lacks write rights, the user can change file text in place. Still, that user cannot unlink the file name or remove it from the folder.
Related guides
In this post