开发者社区> 镜像站> NPM> pssh-exec
pssh-exec
Execute a script over ssh in parallel using Node.js and pipe to and/or from all sessions at once, or individual sessions. Inspired by `pssh(1)`
Last updated 5 years ago by emilbayes .
ISC · Original npm · Tarball · package.json
$ cnpm install pssh-exec 
SYNC missed versions from official npm registry.

pssh-exec

Execute a script over ssh in parallel using Node.js and pipe to and/or from all sessions at once, or individual sessions. Inspired by pssh(1)

Installation

npm install pssh-exec

Example

var pssh = require('pssh-exec')

var hosts = [{host: '127.0.0.1'}, {host: '192.168.1.1'}]

// Will default to the ~/.ssh/id_rsa.pem as per `ssh-exec`
var opts = {username: 'root'}

var sessions = pssh('cat -', hosts, opts, function (err) {
  if (err) {
    console.error(err)
    process.exit(1)
  }

  process.exit(0)
})

process.stdin.pipe(sessions).pipe(process.stdout)

Documentation

This is a high-level wrapper around ssh-exec and multi-duplex-stream.

Of notice is .add(stream), .remove(stream), .destroy([err]) and the constructor:

psshExec(cmd, hosts, [options], [cb])

  • cmd - The command to execute on each machine
  • hosts - An array of hosts objects like the ones defined by ssh-exec. Can be as specific or general as needed to override the defaults defined by ssh-exec, and can override the options object
  • options - Optional, defines the commonalities between the hosts. The hosts objects have higher specificity
  • cb - Optional, callback(err) called when the multi-duplex-stream completes or fails.

License

MIT

Current Tags

  • 1.0.0                                ...           latest (5 years ago)

1 Versions

  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (4)
Dev Dependencies (3)
Dependents (0)
None