n8n-nodes-ssh-command-dynamic-host
v1.0.9
Published
An n8n custom node for running SSH commands on dynamic hosts.
Maintainers
Readme
n8n-nodes-ssh-command-dynamic-host
A custom n8n node that enables SSH command execution on dynamic hosts, which can be provided as part of input data. This is particularly useful when working with lists of remote servers and automating tasks such as monitoring, maintenance, or orchestration.
✨ Features
- Connect to SSH servers using dynamic hostnames from input data (
item.json) - Execute any command remotely
- Full support for multiple items (parallel/batch execution)
- Handles SSH fingerprint verification (non-interactively)
- Compatible with n8n’s native “Continue on error” feature
📦 Installation
Manual (for self-hosted n8n)
Clone or download this repository to your n8n custom nodes folder.
Inside your n8n user folder (
~/.n8n/or/home/user/.n8n/):
mkdir -p ~/.n8n/nodes
cd ~/.n8n/nodes
git clone https://github.com/your-org/n8n-nodes-ssh-command-dynamic-host.git
cd n8n-nodes-ssh-command-dynamic-host
npm install
npm run build
Add this to your environment (if not already enabled):
N8N_CUSTOM_EXTENSIONS=/home/user/.n8n/nodes
Restart your n8n server:
pm2 restart n8n
# or
docker restart n8n
⚙️ Node Configuration
Field Description
Host Field The name of the JSON key in each item that contains the target hostname, OR a literal hostname string.
Username SSH username to connect with.
Password / Key Password (or SSH private key) used for authentication.
Port SSH port (default is 22).
Command The command to run on the remote host. Can use expressions like {{ $json.something }}.
🧠 How It Works
If Host Field value is a string like host, and each item has { "host": "my.server.com" }, the node will extract it dynamically.
If it’s a full hostname (e.g. my.server.com), that static hostname will be used for all items.
The node loops through each input item and connects to the respective server over SSH, running the same command on each.
🔐 SSH Known Hosts Behavior
This node automatically accepts and caches unknown SSH fingerprints (like typing "yes" when manually connecting for the first time).
⚠️ Use caution in production environments! This disables SSH strict host key checking for automation convenience.
✅ Example Use Case
Input:
[
{
"host": "server1.example.com"
},
{
"host": "server2.example.com"
}
]
Set Host Field to host, and your command to something like:
uptime
Output:
[
{
"host": "server1.example.com",
"output": "15:23:45 up 10 days, 2:34, 1 user, load average: 0.00, 0.01, 0.05"
},
{
"host": "server2.example.com",
"output": "15:23:45 up 2 days, 4:12, 3 users, load average: 0.30, 0.25, 0.40"
}
]
🛠 Development
Build
npm install
npm run build
File Structure
nodes/SSHCommandDynamicHost.node.ts – Main node definition and logic.
package.json – Node package setup and metadata.
dist/ – Compiled output folder after running npm run build.
🧪 Testing
Use test SSH servers or local VMs.
Toggle the "Continue On Error" setting in the n8n UI to ensure workflows continue even if one SSH connection fails.
Use SplitInBatches and Wait nodes to rate-limit requests if needed.
📄 License
MIT © 2025 Robertas Z (aka @MadCatMining)