npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

ssh2-pool

v1.0.3

Published

SSH2 server pool helper

Downloads

11

Readme

SSH2Pool Build Status

A library to run multiple ssh commands across multiple machines and get stream or output. It also helps to deal with file transfer across multiple hosts.


Install

npm i ssh2-pool --save


API


ServerPool constructor.

Arguments

  • servers - An object of server pool.

Examples

    var SSH2Pool = require('ssh2-pool');
    
    var servers = 
     {
      ':pool1':['machine1'],
      'machine1':{
        'ssh':{host:'localhost', port:2222, userName:'vagrant',password:'vagrant'}
      }
     };
    
    var pool = new SSH2Pool(servers);

Select a pool of machines.

Arguments

  • name - Name of an environment or a machine.

Returns

  • ServerList - A ServerList object.

Examples

    var SSH2Pool = require('ssh2-pool');
    
    var servers = 
     {
      ':pool1':['machine1'],
      'machine1':{
        'ssh':{host:'localhost', port:2222, userName:'vagrant',password:'vagrant'}
      }
     };
    
    var pool = new SSH2Pool(servers);
    
    pool.env('machine1'); // is a list containing 'machine1' properties
    pool.env(':pool1'); // is also a list containing 'machine1' properties

Execute an Array of commands on server pool and return their output.

Arguments

  • cmds - An Array of commands to execute on server pool.
  • onHostComplete(sessionText, server) - A callback called on command line completion.
    • err an Error.
    • sessionText the completed command line response including the command line.
    • server An ssh server credentials object.
  • onDone(sessionText) - A callback called on session completion.
    • sessionErr an Error.
    • sessionText the completed session response.

Examples

    var SSH2Pool = require('ssh2-pool');
    
    var servers = 
     {
      ':pool1':['machine1'],
      'machine1':{
        'ssh':{host:'localhost', port:2222, userName:'vagrant',password:'vagrant'}
      }
     };
    
    var pool = new SSH2Pool(servers);
    
    pool.env(':pool1').exec(['ls','time'], function(sessionErr, sessionText){
        console.log(sessionText);
    });

A command to execute on a server pool and return their streams.

Arguments

  • cmd - A command to execute on server pool.
  • hostReady(err,stdout,stderr,server,conn) - A callback called on command line sent.
    • err isa Boolean.
    • stdout stderr are Streams.
    • server An ssh server credentials object.
    • conn An ssh Client object.

Examples

    var SSH2Pool = require('ssh2-pool');
    
    var servers = 
     {
      ':pool1':['machine1'],
      'machine1':{
        'ssh':{host:'localhost', port:2222, userName:'vagrant',password:'vagrant'}
      }
     };
    
    var pool = new SSH2Pool(servers);
    
    pool.env(':pool1').run('ls', function(err,stdout,stderr){
        if(err) console.log(err);
        stdout.on('data', function(){
            console.log(''+data);
        });
        stderr.on('data', function(){
            console.log(''+data);
        });
        stdout.on('close',function(){
            conn.end();
        });
    });

Put local file on a remote hosts of a server pool.

Arguments

  • localFile - A local file path to read.
  • remotePath - A remote file path to write.
  • then(err) - A callback called once all files sent.
    • err is an Error.

Examples

    var SSH2Pool = require('ssh2-pool');
    
    var servers = 
     {
      ':pool1':['machine1'],
      'machine1':{
        'ssh':{host:'localhost', port:2222, userName:'vagrant',password:'vagrant'}
      }
     };
    
    var pool = new SSH2Pool(servers);
        
    var localFile = '/tmp/from_local_path';
    var remotePath = '/tmp/to_remote_path';
    
    pool.env(':pool1').putFile(localFile, remotePath, function(err){
        if(err) console.log(err);
        console.log('done');
    });

Put local directory on a remote hosts of a server pool.

Arguments

  • localDirectoryPath - A local directory path to read.
  • remotePath - A remote file path to write.
  • then(err) - A callback called once all files sent.
    • err is an Error.

Examples

    var SSH2Pool = require('ssh2-pool');
    
    var servers = 
     {
      ':pool1':['machine1'],
      'machine1':{
        'ssh':{host:'localhost', port:2222, userName:'vagrant',password:'vagrant'}
      }
     };
    
    var pool = new SSH2Pool(servers);
        
    var localDirectoryPath = '/tmp/from_local_path';
    var remotePath = '/tmp/to_remote_path';
    
    pool.env(':pool1').putDir(localDirectoryPath, remotePath, function(err){
        if(err) console.log(err);
        console.log('done');
    });

Suggestions

On linux you may want to edit /etc/ssh/ssh_config and append

Host 127.0.0.1
   CheckHostIP no
   StrictHostKeyChecking no
   UserKnownHostsFile=/dev/null

This will help to have multiple vagrant box installed on the same machine.


Status

In development. It needs some tests. It misses putFile and readDir implementations.