How to Configure OpenHands SSH Prevent Delete

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up openhands ssh prevent delete controls, you must restrict the agent OS account and lock down SSH keys. You combine Linux file permissions with OpenSSH certificate options to block file removal. Teams often give AI coding agents broad SSH access to remote servers. That wide access lets an automated agent wipe vital folders by mistake. A small prompt error can delete production logs or app code in seconds. How openhands ssh prevent delete works with native rules OpenHands connects to r

SSH Access Management + End-to-End Encryption: 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 openhands ssh prevent delete controls, you must restrict the agent OS account and lock down SSH keys. You combine Linux file permissions with OpenSSH certificate options to block file removal. Teams often give AI coding agents broad SSH access to remote servers. That wide access lets an automated agent wipe vital folders by mistake. A small prompt error can delete production logs or app code in seconds.

How openhands ssh prevent delete works with native rules

OpenHands connects to remote Linux hosts over standard SSH sessions to run tasks. By default, the agent can run any command that its Linux user allows. To stop file deletion, teams start with basic Linux user and group permissions. You create a dedicated user account on the target host for the agent. You remove write permissions on parent directories so the agent cannot unlink files. Linux requires write permission on a folder to delete a file inside it. Teams also use Linux file attributes to mark key logs as append-only. Next, teams use OpenSSH certificates to control how the agent logs in. A certificate authority key signs the agent public key to make a user certificate. This certificate holds a public key, identity data, principal names, and signed options. You can embed a forced command option inside the signed OpenSSH certificate. When the agent logs in, the SSH server runs only that set script. The wrapper script checks the incoming text and drops requests that remove files.

What native SSH controls solve and what they leave open

Native Linux permissions and OpenSSH certificates solve the basic login problem well. They verify who logs in and set static limits on folders. OpenSSH certificates are much simpler than standard TLS certificates and avoid loose keys. You can also set a short time window when you sign the certificate. Yet static OS rules and wrapper scripts leave a big operational gap open. Native SSH setup decides who logs in, not what commands do in flight. If an agent needs to edit a file, its user needs write access. Once the user has write access, it can also truncate or delete files. Simple wrapper scripts struggle to parse complex shell syntax or chained subshells. An agent can bypass a basic text filter using Python or Perl one-liners. It can also overwrite a file with empty text instead of deleting it. Native SSH logs also fail to capture the full output of every command. When an agent breaks a test server, the team cannot see what happened. Also, sensitive data in remote files can leak back into the agent context. Native SSH tools cannot mask emails, phone numbers, card numbers, or national IDs.

Why runtime command inspection matters for AI agents

AI agents like OpenHands build and run shell commands at high speed. They try many ways to solve a task when a command fails. If a static file lock blocks a step, the agent may try workarounds. Teams need a way to inspect every single command right before it runs. Static host files take too much time to update across fifty servers. Maintaining custom shell wrapper scripts on every remote host creates heavy toil. A central check on live traffic stops bad commands before they touch disk. It also lets teams require human approval when an agent runs risky steps. When a human reviews the exact command first, accidental file loss stops cold. Data masking can also rewrite matched fields in results before the agent reads them.

SSH Access Management + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

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 OpenSSH certificates block specific shell commands on their own?

OpenSSH certificates can force a specific command or script to run at login. Still, they cannot inspect interactive shell statements without a custom wrapper script.

Why do Linux folder permissions fail to stop all agent deletions?

Coding agents need write permissions to create new files and save code changes. That same write permission allows the OS user to delete or empty files.

How can teams protect sensitive data during OpenHands SSH sessions?

Teams use runtime data masking to rewrite emails, phone numbers, and card numbers. This step alters matched fields in command output before the agent reads them.

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.