Socket
Socket
Sign inDemoInstall

ssh2-executor

Package Overview
Dependencies
7
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ssh2-executor

Execute one or more commands on the target machine by ssh2 and reduce results.


Version published
Maintainers
1
Created

Readme

Source

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: localhost
    • port {number} Default: 22
    • username {string} Default: administrator
    • password {string} Default: null
  • commands {Array} Commands to execute
  • reduce {function} Reduce function takes next parameters:
    • resutls {Array} Result outputs according to commands
    • timing {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 = require('optimist').argv;
const Executor = require('ssh2-executor');

Executor.run(argv, [
    'whoami',
    'hostname'

], (results, t) => {
    console.log(/^administrator\s?/.test(results[0]) && /^SuperMachine\s?/.test(results[1]));
    console.log(`Execution Time ${t.end - t.beg} ms`);
});

Output:

true
Execution Time 923 ms

Keywords

FAQs

Last updated on 26 Jul 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc