ssh-queue

1.1.11 • Public • Published

ssh-queue

Build Status npm License: MIT

Queues SSH commands to be executed one by one.

Created after encountering a situation where too many simultaneous connection attempts were being made to an external machine.

Wrapper for node-ssh.

Example

 
const sshQueue = require('ssh-queue')
 
// Sets params for all future connections
sshQueue.setConnectionParams({
  host: HOST,
  username: USERNAME,
  password: PASSWORD
})
 
// Access the currently stored connection parameters
sshQueue.getConnectionParams()
 
// Queues upload of localFile to remoteFile
sshQueue.exec('upload', 'localFile', 'remoteFile')
 
// Queues download of remoteFile to localFile
sshQueue.exec('download', 'remoteFile', 'localFile')
 
// Queues execution of command
sshQueue.exec('command', 'ls')
sshQueue.exec('command', 'uptime')
sshQueue.exec('command', 'mkdir src')
// and so on, for any command
 
// Access the current length of the queue
let queueLength = sshQueue.getQueueLength()
 

sshQueue maintains a list of queued interactions with the remote machine (command executions, filePuts, and fileGets), which it works through one by one. A connection is opened when the queue becomes longer than zero, this connection is then maintained until the queue is empty again, at which point it is disposed of.

Connecting and disconnecting is handled automatically, but can be manually triggered via:

 
sshQueue.connect()
 
sshQueue.disconnect()
 

License

This project is licensed under the terms of MIT license. See the LICENSE file for more info.

Dependencies (1)

Dev Dependencies (4)

Package Sidebar

Install

npm i ssh-queue

Weekly Downloads

1

Version

1.1.11

License

MIT

Unpacked Size

12 kB

Total Files

9

Last publish

Collaborators

  • robertforrest