This post was written for Nodejitsu blog and is crossposted here. Nodejitsu loved what I was doing at npmawesome.com and is now supporting the project.

sequest (GitHub: mikeal/sequest, License: MIT) by Mikeal Rogers is a simplified interface to the ssh2 (GitHub: mscdex/ssh2, License: MIT) that was featured earlier. It provides a simplified approach on top of the stream based interface.

For example, each command will complete before the next is sent to the server. If any command returns a non-zero exit code sequest will emit an error which effectively ends the stream and the processing of subsequent commands. This allows you to use sequest in a more serial fashion and not have to worry about handling all the pesky stream events. sequest brings in shortcuts to execute a command as well as put and get files remote files.

npm install sequest

Usage

By default sequest will use your local ssh-agent to authenticate to remote hosts which should make it unnecessary to enter username, password or private key information. So at the bare minimum, sequest code looks like this:

var sequest = require('sequest');

sequest('root@127.0.0.1', 'ls', function (err, stdout) {
  if (err) throw err;
  console.log(stdout.split('n'));
})

My fully functional example on runnable looks like this:

var sequest = require('sequest');
var fs = require('fs');

var opts = {
  command: 'ls -la', 
  privateKey: fs.readFileSync('/root/.ssh/id_rsa')
};

sequest('test_user@127.0.0.1', opts, function (err, stdout) {
  if (err) throw err;
  console.log(stdout.split('n'));
});

What Else?

Checkout the runnable example and github example repository.