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 with elevated privileges (sudo) on remote systems via SSH. It supports both static credential-based and dynamic parameter-based SSH connection configurations. The "Execute with Sudo" operation allows users to run shell commands on a remote device with sudo authentication, enabling administrative tasks that require elevated permissions.

This node is beneficial in scenarios such as:

  • Automating system administration tasks that require root access.
  • Running maintenance scripts or commands on remote Linux servers securely.
  • Integrating privileged command execution into larger automated workflows.
  • Managing network devices or servers where sudo access is necessary for certain operations.

Example use cases:

  • Restarting services that require sudo rights.
  • Installing software packages remotely.
  • Changing system configurations that need elevated privileges.

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 device (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. Supports expressions and environment variables.
Dynamic Private Key Private key content for SSH authentication. Supports expressions and environment variables.
Command The shell command to execute on the remote device with sudo privileges. Examples: ls -la, show version.
Sudo Password Password required for sudo authentication to elevate privileges.
📂 Working Directory (Optional) Optional working directory path on the remote device where the command will be executed. Leave empty to use the default directory. Supports paths like /home/user or ~/.
Advanced Options Collection of additional settings:
- Command Timeout (ms): Maximum wait time for command completion (default 30000 ms).
- Output Parsing: How to parse command output (smart, JSON, table, raw, none).
- Continue on Error: Whether to continue processing other items if some commands fail.
- Cipher Override: Select specific SSH ciphers to override 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 logging.
- Line Ending Style: Choose line ending style (CRLF for Windows, LF for Unix).
- Device Type: Select network device type for optimized handling (generic, Cisco IOS, Aruba OS/AP, Juniper, HP ProCurve, Dell PowerConnect, MikroTik).

Output

The node outputs an array of JSON objects, each representing the result of the executed sudo command per input item. Each output JSON object contains:

  • raw: Raw command output as a string.
  • lines: Array of non-empty lines from the command output.
  • wordCount: Number of words in the output.
  • stderr: Standard error output from the command.
  • exitCode: Exit code of the command (0 indicates success).
  • command: The original command executed (without sudo prefix).
  • cwd: The working directory used for command execution (if specified).
  • sudo: Boolean flag indicating the command was run with sudo.
  • parseOutput: The parsing mode used for the output (e.g., smart, json, table, raw, none).

If binary data were involved (not applicable for this operation), it would be included in the binary property, but this operation focuses on textual command execution.

Dependencies

  • Requires an SSH server accessible from the n8n instance.
  • Needs either stored SSH credentials (with username, host, port, password/private key) or dynamic parameters provided at runtime.
  • Uses the node-ssh library for SSH connections.
  • Supports various SSH cipher configurations; fallback mechanisms are implemented for compatibility.
  • For sudo operations, requires the sudo password to be provided.
  • No external API keys are needed beyond SSH credentials.
  • Environment variables or expressions can be used for dynamic parameters.

Troubleshooting

  • Common Issues:

    • Invalid SSH connection parameters (host format, port range, missing username).
    • Incorrect sudo password causing authentication failure.
    • Dangerous commands are blocked by validation (e.g., rm -rf /, shutdown) to prevent accidental destructive operations.
    • Connection failures due to unsupported SSH ciphers or handshake errors.
    • Timeout errors if commands take longer than the configured timeout.
  • Error Messages & Resolutions:

    • "SSH credentials are required when using credentials mode": Ensure credentials are properly configured and selected.
    • "Invalid host format": Hostname must only contain letters, numbers, dots, and hyphens.
    • "Invalid port number": Port must be between 1 and 65535.
    • "Potentially dangerous command detected": Node prevents execution of risky commands; revise your command.
    • "Command cannot be empty": Provide a valid command to execute.
    • Connection timeout or handshake failed: Try enabling fallback ciphers or adjusting cipher selection in advanced options.
    • Sudo authentication failure: Verify the sudo password is correct and that the user has sudo privileges.
  • Enabling verbose logging helps diagnose connection and execution issues.

Links and References


This summary covers the "Command Execution" resource with the "Execute with Sudo" operation, detailing its purpose, configuration properties, output structure, dependencies, and troubleshooting tips based on static analysis of the provided source code and property definitions.

Discussion