How to Configure OpenAI Agents SDK SSH Prevent Delete
You set up an openai agents sdk ssh prevent delete workflow by using strict Linux user permissions and OpenSSH certificate rules. You also add input checks inside the Python tool function before the agent runs any remote shell command. Engineering teams often give AI agents a shared SSH key to check servers or read logs. When that key maps to a broad Linux role, a bad prompt can wipe out key system files. One wrong command from the model can delete logs, drop app folders, or break a live host.
SSH Agent Forwarding Security + OpenAI API Security: the complete guide
Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.
You set up an openai agents sdk ssh prevent delete workflow by using strict Linux user permissions and OpenSSH certificate rules. You also add input checks inside the Python tool function before the agent runs any remote shell command. Engineering teams often give AI agents a shared SSH key to check servers or read logs. When that key maps to a broad Linux role, a bad prompt can wipe out key system files. One wrong command from the model can delete logs, drop app folders, or break a live host.
How to set up openai agents sdk ssh prevent delete
The OpenAI Agents SDK lets a language model call Python functions as tools. To reach a remote server, developers write a tool function that opens an SSH session. The model picks the command string and passes it to this function. The SDK itself does not know which shell commands are safe or unsafe. It simply runs the Python code you give it and returns the text output.
Your first step is to lock down the remote Linux user account. Do not let the agent log in as the root user or a sudo user. Create a dedicated Linux account that only has read permissions on log folders. If the operating system blocks write actions on a folder, the agent cannot delete files there. You can also mark important log files as append-only at the file system level.
Next, use OpenSSH user certificates instead of static public keys. OpenSSH added certificate support in version 5.4 to simplify key management. A certificate Authority key signs a user public key and embeds identity data and options. When you sign the certificate, you can embed a forced command option. This rule forces the remote host to run one fixed script when the agent logs in. The script can inspect the command string from the agent and reject any delete requests.
What native SSH controls solve and what they miss
Linux file permissions and OpenSSH certificates solve the host login problem well. They ensure the agent only logs in as a known user with a signed key. File system permissions also protect system folders owned by root from being removed. If an agent tries to wipe the main operating system directory, the kernel blocks it.
Still, static OS roles leave a big operational gap during live sessions. Many support agents need write permissions in app folders to clear cache files or restart services. If a Linux user can write to a directory, it can also delete files inside that directory. Standard Linux permissions cannot tell a safe cache clean from a full folder wipe. Also, writing a bash wrapper script to parse every shell command is risky. Attackers or confused models can bypass simple text filters using shell subshells, aliases, or encoded strings. Native SSH controls decide who logs in, not what each individual command does in flight.
SSH Agent Forwarding Security + OpenAI API Security: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Why agent tool wrappers fail at scale
Teams often try to fix this gap by putting blocklists inside the Python tool code. They check the model output for words that remove files or folders before sending it over SSH. This approach breaks quickly when you manage dozens of agents across many servers. Every developer writes slightly different filter rules in their local agent code.
Also, the agent host still holds the raw SSH private key on disk. If the agent container gets compromised, the attacker takes the key and skips the Python checks. They can open a direct SSH session and run any command the Linux role allows. Keeping keys on agent machines and maintaining regex filters in app code does not scale safely.
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 the OpenAI Agents SDK block destructive SSH commands on its own?
No, the SDK only routes model arguments into the Python functions you define. You must enforce command rules on the target host or in the network path.
Do read-only Linux users stop all file deletions over SSH?
Read-only users cannot delete system files or protected app data. Still, they can still write to and delete files in shared temporary folders.
How do OpenSSH certificates help with AI agent security?
OpenSSH certificates let you set a validity window and embed command limits when signing a key. This stops agents from using forever keys that never expire.
Related guides
In this post