The NODE-RED-EXPECT-TCL
is a set of custom Node-RED nodes designed to establish an interactive SSH session to a remote server. It allows dynamic execution of commands within this session based on input messages, providing flexibility for automation tasks that require SSH connectivity.
- Dynamic Connection Parameters: Allows SSH connection details (host, port, username, password) to be specified dynamically via input messages, with the option to fall back on static configurations.
- Interactive Session Management: Maintains an interactive SSH session, enabling the execution of multiple commands in the context of a single, persistent session.
- Connection Status Feedback: Provides visual feedback within the Node-RED editor on the connection status, changing node color to indicate when the session is connected or disconnected.
git clone
cd node-red-nodespect
npm install
Pallet Manager to come
-
Configuration: Drag the
SSH Connection Open
into your flow. Optionally, configure static default connection parameters (host, username, password, port, privatekey, passkey) in the node's settings if you want to have fallback values. -
Dynamic Parameters: Send an input message to the node with payload properties specifying
host
,port
,username
,password
,privateKey
, and/orpassphrase
for dynamic connection setup. Example message payload for dynamic parameters:{ "payload": { "host": "example.com", "port": 22, "username": "user", "password": "password", "privateKey": "-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----", "passphrase": "password" } }
-
Executing Commands: Once connected, send additional input messages with the
payload.command
property set to the command you wish to execute on the remote SSH server. The node maintains the session for subsequent commands. -
Connection Status: Monitor the node's status in the Node-RED editor for connection feedback. A green node indicates an active connection, while red signifies disconnected.
-
Session Closure: To close the session, either deploy changes, stop the flow, or send a command to explicitly exit the session if needed.
- Handle sensitive information like passwords with care. Prefer dynamic input for sensitive details and secure the flow of these messages within your Node-RED environment.
- Consider using SSH keys for authentication where possible for enhanced security.
- Requires the
ssh2
npm package for SSH connectivity.
- Grey Dziuba / GitHub @gdziuba