How to Configure CrewAI SSH Prevent Delete
To set up crewai ssh prevent delete rules, bind the agent to a restricted Linux user and lock down its OpenSSH key. You also need runtime command checks to stop destructive shell actions before they run. Engineering teams often give AI agents a standard SSH key to check logs or restart services. When that account has broad write rights, a bad prompt can wipe files or drop folders. A safe setup separates login rights from what the agent can run inside the shell. How crewai ssh prevent delete wo
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 crewai ssh prevent delete rules, bind the agent to a restricted Linux user and lock down its OpenSSH key. You also need runtime command checks to stop destructive shell actions before they run. Engineering teams often give AI agents a standard SSH key to check logs or restart services. When that account has broad write rights, a bad prompt can wipe files or drop folders. A safe setup separates login rights from what the agent can run inside the shell.
How crewai ssh prevent delete works in native Linux and OpenSSH
In a CrewAI project, an agent uses a custom tool to run remote commands over SSH. The tool loads a private key or user certificate from disk and opens a session. The target host checks that key against its allowed list and starts a shell for that Linux user. Everything the agent runs next inherits the file permissions of that local account.
To prevent file deletion natively, admins start with Linux file ownership and groups. You create a dedicated user for the CrewAI worker and remove its write access on key folders. If the agent lacks write permission on a directory, the system blocks it from unlinking files inside. You can also set the immutable or append-only attribute on log folders so files stay safe.
On the OpenSSH side, admins can sign user keys with a Certification Authority key. An OpenSSH certificate holds a public key, identity info, user names, and signed options. You can attach a forced command option to that key or certificate. When the CrewAI tool logs in, OpenSSH ignores the agent command and runs a wrapper script instead. That wrapper script reads the requested command and rejects strings that contain remove or truncate verbs.
Where native OS and SSH rules fall short for AI agents
Native Linux permissions and wrapper scripts solve the basic login problem. They make sure the CrewAI process only enters the host as a known, low-privilege user. They also work well when an agent only needs to run one fixed script every time.
Still, AI agents are built to investigate issues and pick commands on the fly. A static wrapper script is hard to maintain when an agent runs complex shell pipelines. Attackers or confused models can bypass simple word filters by using subshells, loops, or scripting languages. For example, an agent might call a Python one-liner or a find command to delete files without using the standard remove verb.
SSH Access Management + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
File permissions also create a tough trade-off when an agent needs to fix an app. If a CrewAI task must write a temp file or clear a cache, you must grant write access to that folder. Once the Linux user has write access to a directory, the OS allows it to delete any file in that same path. Native SSH setup decides who logs into the server, not what individual commands do in flight.
Best practices for safer agent shell workflows
Break your agent tools into small, single-purpose actions rather than one open shell tool. Give read-only diagnosis agents their own Linux account with zero write paths anywhere on disk. Keep any private keys off the agent container so a prompt trick cannot read them out. Finally, review every write or delete action before it reaches the remote shell.
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 on the host. It checks callers with OpenSSH certificates and works with ssh, sftp, scp, and rsync clients.
When a caller runs a one-shot command or moves a file, hoop.dev guardrails check the command or path before it runs. Then 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 a Linux wrapper script block every delete command from a CrewAI agent?
No, because shell syntax offers many ways to remove data without the standard remove command. A wrapper script only works well if it allows a strict list of exact commands.
Does a read-only Linux user stop CrewAI from deleting files?
Yes, if the account has no write permissions on the parent directories or files. Still, the agent will also fail if its task requires writing temp files or updating configs.
Why should we avoid giving a shared SSH key to a CrewAI worker?
A shared key makes it impossible to tell which agent or human ran a bad command in system logs. It also gives the agent the same broad delete rights as your human engineers.
Related guides
In this post