SSH (Dynamic)

Execute commands via SSH with dynamic credential data

Actions3

Overview

This node enables downloading files from a remote server over SSH. It connects to the specified host using provided credentials, navigates to the given file path, and downloads the file content into the workflow's binary data. This is useful for automating retrieval of files such as logs, reports, or any documents stored on remote systems accessible via SSH.

Common scenarios:

  • Automatically fetching daily generated reports from a remote Linux server.
  • Downloading log files for analysis in an automated workflow.
  • Retrieving configuration backups from network devices or servers.

Example:
You want to download /home/user/invoice.txt from a remote server at IP 192.168.1.10. You configure the node with the host, port, username, and authentication details, specify the full file path, and set the binary property name (e.g., data). The node downloads the file and outputs it as binary data under the specified property, ready for further processing or saving.

Properties

Name Meaning
Host The IP address or hostname of the SSH server to connect to (e.g., 127.0.0.1).
Port The SSH port number, default is 22.
Username The username to authenticate with on the remote server.
Authentication Method of authentication: either Password or Private Key.
Password Password for SSH login if Password authentication is selected.
Private Key Private key string used for SSH authentication if Private Key method is selected.
Passphrase Optional passphrase for the private key if it is encrypted.
Path Full path including filename of the file to download from the remote server (e.g., /home/user/invoice.txt).
File Property The name of the binary property in the output where the downloaded file will be stored (default is data).
Options → File Name Optional override for the downloaded file's name in the binary data.

Output

The node outputs an array of items, each containing:

  • json: The original input JSON data passed through unchanged.
  • binary: An object holding the downloaded file's binary data under the property name specified by File Property. This binary data represents the contents of the downloaded file.

If the "File Name" option is set, it overrides the filename metadata associated with the binary data.

Dependencies

  • Requires an SSH server accessible with the provided host, port, username, and authentication credentials.
  • Uses the node-ssh library internally to establish SSH connections and transfer files.
  • Temporary local storage is used during file download before loading into binary data.
  • No additional n8n-specific credentials are required beyond providing the necessary connection details and authentication information.

Troubleshooting

  • Invalid path errors: Paths starting with ~ but not followed by / are rejected. Use full absolute paths or ~/ to represent home directory.
  • Authentication failures: Ensure correct password or private key and passphrase are provided. Incorrect credentials will cause connection failure.
  • File not found: If the specified file path does not exist or is inaccessible due to permissions, the node will error.
  • Temporary file cleanup: The node uses temporary files during download; ensure the environment allows creating and deleting temp files.
  • Connection issues: Network problems or incorrect host/port can prevent SSH connection.

To resolve errors:

  • Double-check all connection parameters.
  • Verify file path correctness and permissions on the remote server.
  • Confirm that the private key format is valid if used.
  • Enable "Continue On Fail" in the node settings to handle individual item errors gracefully.

Links and References

Discussion