Simplify running commands on multiple systems

aux - DRAFT

To simplify scripting access to multiple machines, we present here a simple API that makes running commands on a POSIX compliant system, either local or remote, nothing short of a breeze.

Remote commands are run via ssh, and the aux binary can work as a proxy script, that enables an administrator to granulate access control.

On the machine you wish to control, you will probably want to use aux as a proxy script. This allows you to restrict client access to only pre specified commands. In this case you should just run:

npm install -g aux

When using the aux library to control some machines from your application, just install as a dependency:

npm install aux
aux --user <username> --add-key <pub_key>
aux --user <username> --remove-key
aux [--user <username>] --add-command <command>
aux [--user <username>] --remove-command <command>
var aux = require('aux');
aux.testing = new aux.remote({host: ''});
aux.staging = new aux.remote(
  {host: ''},
  {host: ''},
  {host: ''});
// optional callback with args: ({Error}, {Array}) 
aux.local('command', callback); 
aux.testing('command1', 'command2');
// if callback is provided, it is called when all servers have responded, with 
// args: ({Error}, {Array}) 
aux.staging('command', callback); 

As a contrived example, say we want enable the happy user, Fred, restart nginx on our Ubuntu server

  1. First we add Fred's public authentication key to our server
aux --user fred --add-key "ssh-rsa AAAA...=="
  1. Next we allow Fred to restart any service on the system
aux --user fred --add-command "sudo service \w+ restart"
  1. Create a simple script for Fred to use on his machine
var aux = require('aux');
var server = new aux.remote({host: ''});
server('sudo service nginx restart', function (errresult) {
  if (err) throw err;

Now Fred can simply call this script to restart nginx on the server.

node restart_nginx.js
var aux = require('aux');
var host1 = {host: ''};
var host2 = {host: '', user: 'another_user'};
var host3 = {host: ''};
var host3 = {host: ''};
var remote = new aux.remote(host4);
var realm1 = new aux.realm(host1, host2, host3);
var realm2 = new aux.realm(remote, host3);
var realm3 = new aux.realm(realm1, realm2);
remote('cmd', function (errresult) {});
realm1('cmd', 'cmd2', function (errresult) {
  // result  is an array of all the results 

Remotes are streamable

var aux = require('aux');
var server1 = aux.remote({host: ''});
var server2 = aux.remote({host: ''});