SSH Nexus

Advanced SSH automation hub with intelligent connection management and network device support. Built with ❤️ by Sarryaz

Overview

The node "SSH Nexus" provides advanced SSH automation capabilities, focusing on executing commands on remote systems securely and flexibly. Specifically, the Command Execution > Execute Single Command operation allows users to run a single shell command on a remote device over SSH.

This node is beneficial in scenarios such as:

  • Automating routine server management tasks (e.g., checking disk usage, restarting services).
  • Running network device commands remotely.
  • Integrating remote system control into workflows without manual SSH login.
  • Executing privileged commands with sudo when elevated permissions are required.

Practical example: You want to retrieve the list of files in a directory on a remote Linux server. Using this node, you configure the SSH connection, specify the ls -la command, and get the output directly in your workflow for further processing or alerting.

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 of the remote system (required if using Dynamic Parameters mode). Supports expressions and environment variables.
Dynamic Port SSH port number (default 22). 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 if using password authentication). Supports expressions and environment variables.
Dynamic Private Key Private key content for SSH authentication (optional alternative to password). Supports expressions and environment variables.
Command The shell command string to execute on the remote device (e.g., ls -la, show version). Required for this operation.
📂 Working Directory (Optional) Optional working directory path where the command will be executed (e.g., /home/user). Leave empty to use the default directory.
Advanced Options Collection of additional settings:
- Command Timeout (ms): Max wait time for command completion.
- Output Parsing: How to parse command output (smart, json, table, raw, none).
- Continue on Error: Whether to continue processing other items if one fails.
- Cipher Override: Select specific SSH ciphers to use.
- 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 (CRLF or LF).
- Device Type: Select network device type for optimized handling (e.g., Cisco IOS, Juniper).

Output

The node outputs an array of JSON objects, each corresponding to an input item processed. For the Execute Single Command operation, each output JSON contains:

  • raw: Raw command output as a string.
  • lines: Array of non-empty lines from the output.
  • wordCount: Number of words in the output.
  • stderr: Standard error output from the command.
  • exitCode: Exit code returned by the command.
  • command: The executed command string.
  • cwd: The working directory used (if specified).
  • parseOutput: The parsing mode applied to the output.
  • hasError: Boolean indicating if an error was detected in parsing.
  • sudo: Boolean flag indicating if the command was run with sudo (only for sudo execution).
  • Additional fields may include structured parsed data depending on the selected output parsing mode.

If binary data were involved (not applicable for this operation), it would be included under a binary property.

Dependencies

  • Requires an active SSH server accessible from the n8n instance.
  • Needs either stored SSH credentials or dynamic SSH connection parameters (host, port, username, password/private key).
  • Uses the node-ssh library internally for SSH connections.
  • No external API keys are required beyond SSH authentication credentials.
  • Recommended to configure SSH credentials securely within n8n credential manager when using "Use Credentials" mode.

Troubleshooting

  • Invalid host format error: Occurs if the dynamic host contains invalid characters. Ensure the hostname or IP only includes letters, numbers, dots, and hyphens.
  • Invalid port number error: Port must be between 1 and 65535.
  • Empty command error: The command field cannot be empty.
  • Potentially dangerous command detected: Commands that can cause destructive actions (e.g., rm -rf /, shutdown) are blocked for safety.
  • SSH connection failures: May result from incorrect credentials, network issues, or unsupported cipher algorithms. Enabling verbose logging helps diagnose these.
  • Timeouts: If commands take longer than the configured timeout, increase the "Command Timeout" value.
  • Continue on Error: If enabled, the node will process all items even if some commands fail; otherwise, it stops at the first failure.

Links and References

Discussion