-
Notifications
You must be signed in to change notification settings - Fork 1
Task: SSH Command
This is a highly parallel SSH task for managing remote computers, clouds etc. The asynchronous nature of the task allows to run thousands of parallel remote tasks. Will also track success, failure and return code for remote scripts.
Thus, can be used to manage distributed, parallel, XForge build farms itself, using parallelized master build scipt.
The supported remote hosts are
- Linux (all vendors and versions)
- MacOS
- *BSD
- Windows (with SSH server enabled)
Usage
const {ssh_cmd} = require(`${CONSTANTS.EXTDIR}/ssh_cmd.js`);
...
...
{exitCode, stdout, stderr} = await ssh_cmd(host, user, password, hostkey, scriptPath, [...arguments].slice(4), true)
...
...
The scriptPath is the shell script to run remotely. Typically any command can be executed, including XForge, wrapped in a shell script.
Additional arguments can be sent to the script, using [...arguments].slice(4) which can then pass additional arguments sent to XForge's command line to the remote script directly.
See the file samples/remoteCmd.xf.js for a working sample.
The command will return remote shell scripts exit code (must be 0 for success) and stdout and stderr streams collected. If the last parameter is true then XForge will prints the remote streams as they happen, if it is false it will not. Regardless XForge will return the collected output at the end of this command.
Usage for the sample
node xforge -c -f samples/remoteCmd.xf.js -o <remote host or IP> -o <user id> -o <password> -o <remote host SSH key> -o <shell script to run remotely> [-o <additional arguments to send to the remote script repeated as many times as necessary>]*
The following is a concrete sample to a host with IP 10.23.32.21, with user root, password helloHackers, hostkey be:27:56:ec:df:b0:69:9d:1a:35:d0:9a:ed:37:51:9c and wildRemoteCmd.sh which runs any command sent in as an argument, to get the directory listing of the root's home directory
node xforge -c -f samples/remoteCmd.xf.js -o 10.23.32.21 -o root -o helloHackers -o "be:27:56:ec:df:b0:69:9d:1a:35:d0:9a:ed:37:51:9c" -o samples/wildRemoteCmd.sh -o "ls -alrt /root"