Overview
This node enables executing commands on a remote server via SSH. It supports connecting using either stored credentials or dynamic parameters, with authentication by password or private key. The primary use case is to remotely run shell commands and retrieve their output, which is useful for system administration, automation, and remote management tasks.
Practical examples include:
- Running
ls -lato list files in a directory on a remote Linux server. - Executing deployment scripts or maintenance commands remotely.
- Gathering system information or logs from remote machines.
Properties
| Name | Meaning |
|---|---|
| Connection Type | Choose between using stored credentials or specifying connection parameters dynamically. |
| Authentication | Select the authentication method: Password or Private Key. |
| Host | Hostname or IP address of the SSH server (required if using dynamic parameters). |
| Port | Port number of the SSH server (default 22, required if using dynamic parameters). |
| Username | Username for SSH authentication (required if using dynamic parameters). |
| Password | Password for SSH authentication (required if using dynamic parameters and password auth). |
| Private Key | Private key string for SSH authentication (required if using dynamic parameters and private key auth). |
| Passphrase | Passphrase for the private key, if applicable. |
| Command | The shell command to execute on the remote server (required). |
| Working Directory | Directory on the remote server where the command will be executed (default "~"). |
Output
The node outputs JSON data containing the result of the executed command with the following structure:
{
"stdout": "string", // Standard output from the command execution
"stderr": "string", // Standard error output from the command execution
"exitCode": "number", // Exit code returned by the command
"success": true|false, // True if exitCode is 0, otherwise false
"command": "string", // The command that was executed
"workingDirectory": "string" // The directory where the command was executed
}
No binary data is produced by this operation.
Dependencies
- Requires an SSH server accessible over the network.
- Supports two authentication methods: password or private key.
- If using stored credentials, appropriate API key credentials must be configured in n8n.
- Uses the
node-sshlibrary internally to manage SSH connections. - The node handles path expansion for home directories (
~) on the remote server.
Troubleshooting
- SSH Connection Failed: Commonly caused by incorrect host, port, username, or authentication details. Verify all connection parameters and credentials.
- Invalid Path Error: If the working directory path starts with
~but is not followed by/, the node throws an error. Use~/to represent the home directory correctly. - Command Execution Errors: If the command returns a non-zero exit code, the
successfield will be false, andstderrmay contain error messages. Check the command syntax and permissions on the remote server. - Authentication Issues: Ensure the private key is properly formatted and passphrase is correct if used. For password authentication, verify the password is accurate.
- Timeouts or Network Issues: Network connectivity problems can cause SSH connection failures. Confirm network access and firewall settings.