How to Configure n8n SSH Least Privilege

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up n8n ssh least privilege by creating a restricted Linux user for your workflows. You then pair that account with a scoped SSH key and strict host rules. Many teams start by giving their workflow engine a broad admin key to save time. That choice lets one broken workflow or bad prompt change files across the whole server. How native n8n ssh least privilege works In n8n, workflows run remote shell steps through dedicated nodes or sub-workflows. When you build an AI Agent node, you att

Least Privilege Principle + SSH Access Management: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

You set up n8n ssh least privilege by creating a restricted Linux user for your workflows. You then pair that account with a scoped SSH key and strict host rules. Many teams start by giving their workflow engine a broad admin key to save time. That choice lets one broken workflow or bad prompt change files across the whole server.

How native n8n ssh least privilege works

In n8n, workflows run remote shell steps through dedicated nodes or sub-workflows. When you build an AI Agent node, you attach a chat model and one or more tools. The agent then decides which tools to call to finish its task. A workflow can also call a child workflow that runs an SSH step on a Linux host.

To keep that login narrow, you start on the target Linux server. You create a service user that owns no system files and has no admin rights. You place that user in a group that can read only the folders the job needs. If the job must restart a service, you allow only that single command in the system rules.

Next, you manage the SSH key or OpenSSH certificate used by the workflow. OpenSSH certificates hold a public key, identity info, valid principals, and signed options from a CA key. Using a certificate lets you bind the key to one principal name and a short time window. You can also restrict which source IP addresses can log in with that key.

Restricting commands on the target Linux host

Linux and OpenSSH give you native ways to lock down what a key can run. In the user authorized keys file or certificate options, you can force a specific command. When the n8n workflow logs in, the SSH daemon runs only that fixed script. It ignores any other shell command that the workflow tries to send over the session.

This works well when an n8n workflow performs one repeatable job, like checking disk space. You write a small wrapper script on the host and point the key to that script. You also turn off port forwarding, agent forwarding, and pseudo-terminal allocation for that key. That stops the workflow from using the host as a stepping stone to other machines.

When a workflow needs to run three or four distinct checks, a single forced command feels stiff. Teams often write a small case script on the server to read an argument and pick a safe action. The script rejects anything outside its short list of approved tasks. That keeps the Linux account locked down even if someone edits the workflow step later.

Least Privilege Principle + SSH Access Management: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native SSH setup solves and what it misses

Native Linux permissions and OpenSSH options solve the host login problem well. They verify which machine logs in and which local user account runs the process. They also stop a service account from reading private folders that belong to other apps. If a key only allows one forced script, the host blocks raw shell access at the door.

Still, static host rules are hard to maintain when workflows grow more dynamic. If an n8n AI Agent node uses a tool to inspect servers, fixed scripts break down fast. Engineers often widen the Linux user rights so the agent or workflow can run varied checks. Once you grant a general shell, the host setup only checks who logs in at the start.

Native SSH setup does not inspect individual commands in flight or pause risky actions for human review. It also stores the private key inside the automation tool credential store across many runs. And when command output returns emails, phone numbers, or card numbers, standard SSH returns everything in plain text. Teams need runtime controls when static host scripts no longer fit their workflows.

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

Should n8n workflows share one SSH key across multiple servers?

No, sharing one SSH key across hosts expands the blast radius if a credential leaks. Give each workflow or host role its own dedicated key and Linux user account. Using OpenSSH certificates signed by a CA key makes managing separate host principals much simpler.

How do you limit what an n8n AI Agent can run over SSH?

In n8n, the AI Agent node decides which attached tools to call to complete a task. Do not give the agent a tool that passes freeform text straight into a remote shell. Instead, connect a Call n8n Workflow Tool that runs fixed, pre-approved scripts on the target host.

Why are Linux file permissions not enough for SSH automation safety?

Linux file permissions only govern which files a local user account can read, write, or run. A workflow with valid read access can still pull sensitive customer data like emails or card numbers. File permissions also cannot require real-time approval before a valid user runs a destructive command.

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.