ssh2-executor
Execute one or more commands on the target machine by ssh2 and reduce results.
Installation
Install ssh2-executor using npm:
$ npm install ssh2-executor --save-dev
Usage
const Executor = require('ssh2-executor');
Executor.run({object} argv, {Array} commands, {function} reduce);
argv
{object} SSH2 connection options:host
{string} Default: localhostport
{number} Default: 22username
{string} Default: administratorpassword
{string} Default: null
commands
{Array} Commands to executereduce
{function} Reduce function takes next parameters:resutls
{Array} Result outputs according to commandstiming
{object} total beg, end ms
Example
Execute whoami
and hostname
commands on the target machine, compare with the expected values and out boolean answer:
'use strict';const argv = argv;const Executor = ; Executor;
Output:
true
Execution Time 923 ms