How to Configure n8n SSH Prevent Delete

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up n8n ssh prevent delete controls, restrict the remote Linux user and command scope. You pair scoped OpenSSH rules with dedicated workflow accounts to stop file removal. Teams often link an n8n workflow or AI Agent node to a target server. They use a single shared root key or broad admin account for every task. When a workflow bug or bad prompt runs a delete command, nothing stops it. Critical files vanish before anyone can step in to stop the job. How native n8n ssh prevent delete con

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 n8n ssh prevent delete controls, restrict the remote Linux user and command scope. You pair scoped OpenSSH rules with dedicated workflow accounts to stop file removal. Teams often link an n8n workflow or AI Agent node to a target server. They use a single shared root key or broad admin account for every task. When a workflow bug or bad prompt runs a delete command, nothing stops it. Critical files vanish before anyone can step in to stop the job.

How native n8n ssh prevent delete controls work

In n8n, an AI Agent node links a chat model to one or more tools. The agent picks which tools to call so it can finish a task. Teams often attach a sub-workflow or custom tool that runs remote shell commands. The workflow logs in to the remote host over the network using an account key. OpenSSH checks the key or signed user certificate and starts a shell for that account.

Because n8n sends a raw text string, the remote Linux host enforces the rules. To stop file removal natively, admins create a dedicated Linux user for the workflow. They strip write permissions from folders that hold critical system files and data. Admins also set file attributes on important logs so only root can remove them. They can also use OpenSSH options or a wrapper script on the authorized key. That script checks the incoming command string and blocks known delete words before execution.

What native Linux rules solve and what they miss

Dedicated Linux accounts and file permissions solve the most basic access problems. They keep the n8n workflow out of system folders that belong to other users. If a workflow only needs to read disk space, a read-only user works well. OpenSSH certificates can also bind a key to specific user names and options.

Still, many workflows must write temp files, rotate logs, or update app code. In Linux, write permission on a folder allows a user to delete files inside it. If the n8n account can create a file, it can also delete sibling files. Wrapper scripts that grep for delete commands are easy to bypass in practice. An agent or script can overwrite a file with empty text or call Python. Native host setup decides who logs in, not what each command does in flight.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Why AI agents increase remote shell risk

Standard workflows run fixed scripts, so teams can review the text ahead of time. An n8n AI Agent node works in a very different way during a run. The chat model reads user input and decides which tool to call next. If the agent passes dynamic arguments to an SSH workflow tool, behavior changes fast.

A vague prompt can cause the model to clean up a folder by mistake. Without inspection on the wire, the remote shell runs that delete request right away. Also, when sensitive text comes back from a remote file read, it returns raw. Without result filtering that rewrites emails or card numbers, raw secrets reach the model. Teams need a way to inspect every command and output without rewriting Linux permissions.

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 n8n block delete commands inside the SSH node itself?

No, the built-in node only sends the command string to the remote server. It does not parse shell syntax or block destructive flags before sending them out.

Why does a Linux user with write access also get delete access?

On Linux filesystems, deleting a file changes the folder index where the file lives. Any user with write access to a folder can remove files inside that folder.

How do OpenSSH certificates help with n8n workflow security?

A certificate holds a public key, identity data, allowed user names, and signed options. Admins can sign keys with a CA key instead of copying static keys everywhere.

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.