Callback-based api behind ssh2 to open an SSH connection
The Node.js ssh2-connect package extends the
ssh2 module to provide
a simplified callback-back approach to initiate a new SSH connection.
Function signature is
The main purpose of this module is to simplify the creation of an SSH connection. For example, the original ssh2 code...
ssh2 = require 'ssh2'connection =connectionon 'error'connectionend# not ready at allconnectionon 'ready'-># ready to goconnectionconnect options
...is simplified to:
connect = require 'ssh2-exec/lib/connect'connect options# this is faster to write
Options are inherited from the ssh2
function with a few additions:
retryAttempt to reconnect multiple times, default to "1".
waitTime to wait in milliseconds between each retry, default to "500".
Note, the "privateKeyPath" option is provided as a conveniency to prepare the "privateKey" property.
Additionally, all options may be provided in camalize (the default in ssh2) or underscore form. For example, both "privateKey" and "private_key" would be interprated the same.
This is OSS and licensed under the new BSD license.
npm install ssh2-connect
The example is using both the "ssh2-connect" and "ssh2-fs" modules.
connect = ;fs = ;;
Compare this to the more verbose alternative using the original ssh2 module.
ssh2 = ;fs = ;connection = ;connection;connection;connection;
Tests are executed with mocha. To install it, simple run
npm install, it will install
mocha and its dependencies in your project "node_modules" directory.
To run the tests:
The tests run against the CoffeeScript source files.
The test suite is run online with Travis against Node.js version 0.9, 0.10 and 0.11.