SSH Command (Dynamic Host)

Execute SSH commands on a host dynamically provided by item input

Overview

This node executes SSH commands on a dynamically specified host provided by each input item. It is useful for scenarios where you need to run commands on multiple remote servers, with the host information coming from the input data itself. For example, it can be used to automate server management tasks, gather system information, or deploy updates across a range of hosts dynamically.

Use Case Examples

  1. Running a diagnostic command on a list of servers where each server's IP or hostname is part of the input data.
  2. Automating deployment scripts on multiple remote machines by specifying the target host dynamically in the workflow input.

Properties

Name Meaning
Host Field or Host Specifies either a direct hostname/IP or the name of a field in the input JSON that contains the hostname or IP address to connect to.
Port The SSH port number to connect to on the remote host, defaulting to 22.
Username The username to authenticate with on the remote SSH host.
Password The password to authenticate with on the remote SSH host.
Command The SSH command string to execute on the remote host.

Output

JSON

  • host - The hostname or IP address of the remote SSH server where the command was executed.
  • output - The combined standard output and standard error result of the executed SSH command.
  • error - Error message if the host could not be resolved or the SSH command execution failed.

Dependencies

  • ssh2 library for SSH connections

Troubleshooting

  • If the host field is not found in the input JSON or is empty, the node returns an error indicating the host could not be resolved. Ensure the host field name is correct and present in the input data.
  • SSH connection errors may occur due to incorrect credentials, network issues, or SSH server configuration. Check username, password, port, and network accessibility.
  • Timeouts can happen if the SSH server does not respond within 10 seconds (readyTimeout). Increase timeout or verify server availability if needed.

Discussion