SSH Nexus
Actions22
- Command Execution Actions
- File Operations Actions
- Network Device Actions
- System Information Actions
- Connection Health Actions
Overview
The Execute Multiple Commands operation of this SSH Nexus node enables users to run multiple shell commands sequentially on a remote system over SSH. It supports flexible input formats for commands, including plain text lists and JSON arrays, and allows customization of execution parameters such as wait time between commands and output parsing style.
This operation is beneficial in scenarios where complex automation or configuration tasks require running several commands in order, for example:
- Network device configuration or status checks by sending multiple show or config commands.
- Batch maintenance scripts on Linux servers.
- Collecting various system information outputs in one go.
Practical examples include:
- Running a list of diagnostic commands on a router:
show version,show interfaces,show ip route. - Executing a sequence of Linux commands to update software, clean caches, and restart services.
- Sending multiple commands with custom delays to avoid overwhelming the remote device.
Properties
| Name | Meaning |
|---|---|
| Configuration Mode | Choose how to configure the SSH connection: - Use Credentials: Use stored SSH credentials (recommended for security). - Dynamic Parameters: Use dynamic parameters from previous nodes or environment variables. |
| Dynamic Host | Hostname or IP address for SSH connection (required if using Dynamic Parameters mode). Supports expressions and environment variables. |
| Dynamic Port | SSH port number (default 22) when using Dynamic Parameters mode. Supports expressions and environment variables. |
| Dynamic Username | Username for SSH login (required if using Dynamic Parameters mode). Supports expressions and environment variables. |
| Dynamic Password | Password for SSH login (optional, supports expressions and environment variables). |
| Dynamic Private Key | Private key content for SSH authentication (optional, supports expressions and environment variables). |
| Commands List | The commands to execute sequentially, entered as text. Supports comments starting with # and empty lines to separate command groups. |
| Commands Format | Input format for commands: - Text List (One Per Line): Simple text format. - JSON Array: Advanced JSON format with command objects {command:string, waitTime:number}.- Simple Array: JSON array of strings. |
| Wait Time Between Commands (ms) | Delay in milliseconds between executing each command to prevent overwhelming the remote system (default 1000 ms). |
| Advanced Options | Collection of advanced settings: - Command Timeout (ms): Max time to wait for each command to complete (default 30000 ms). - Output Parsing: How to parse command output ( smart, json, table, raw, none).- Continue on Error: Whether to continue executing remaining commands if one fails. - Cipher Override: Select specific SSH ciphers overriding credential defaults. - Try Fallback Ciphers: Automatically try alternative ciphers if primary ones fail. - Retry Delay (ms): Delay between connection retry attempts. - Verbose Logging: Enable detailed debug logs. - Line Ending Style: Choose line ending style for commands ( CRLF or LF).- Device Type: Select network device type for optimized handling (e.g., Cisco IOS, Juniper, Generic). |
Output
The output JSON contains a commands array with an entry per executed command. Each command result includes:
command: The executed command string.exitCode: Numeric exit code returned by the command.stderr: Standard error output text.stdoutor parsed output fields depending on parsing option:- If parsing is enabled (
smart,json,table,raw), structured data or formatted text is provided. - If parsing is disabled (
none), raw output and basic stats like line count and word count are included.
- If parsing is enabled (
parseOutput: The parsing mode used.commandIndex: Position of the command in the sequence (1-based).totalCommands: Total number of commands executed.- Optional
cwd: Working directory if specified. - Optional
hasError: Boolean indicating if output parsing detected errors.
If binary data were involved (not applicable here), it would be included in the binary property.
Example snippet of output JSON structure:
{
"commands": [
{
"command": "show version",
"exitCode": 0,
"stderr": "",
"stdout": "...",
"parseOutput": "smart",
"commandIndex": 1,
"totalCommands": 3
},
{
"command": "show interfaces",
"exitCode": 0,
"stderr": "",
"stdout": "...",
"parseOutput": "smart",
"commandIndex": 2,
"totalCommands": 3
}
]
}
Dependencies
- Requires an active SSH server accessible via network.
- Needs either stored SSH credentials configured in n8n or dynamic SSH connection parameters supplied at runtime.
- Uses the
node-sshlibrary internally for SSH connections. - Supports private key or password authentication.
- For network devices, device-specific command sets and prompt handling are built-in.
- No additional external services required beyond SSH access.
Troubleshooting
- Invalid host format error: When using dynamic parameters, the host must only contain letters, numbers, dots, and hyphens. Avoid spaces or special characters.
- Port number out of range: Ensure the SSH port is between 1 and 65535.
- Empty commands list: The node throws an error if no valid commands are found; ensure commands are not empty or commented out entirely.
- Potentially dangerous commands blocked: Commands containing destructive patterns like
rm -rf /,dd if=/dev/zero,mkfs,shutdown, orrebootare rejected to prevent accidental damage. - SSH connection failures: Check credentials, network connectivity, and cipher compatibility. Enabling verbose logging can help diagnose handshake or authentication issues.
- Command timeout: Increase the command timeout if commands take longer than default 30 seconds.
- Continue on error: Enable this option to allow subsequent commands to run even if some fail.
- Parsing errors: If output parsing fails, try switching to
rawornoneparsing modes.