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.
Install
Server
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
Client project
When using the aux library to control some machines from your application, just install as a dependency:
npm install aux
Usage
Server
aux --user <username> --add-key <pub_key>
aux --user <username> --remove-key
aux [--user <username>] --add-command <command>
aux [--user <username>] --remove-command <command>
Client project
var aux = ; auxtesting = host: 'testing.example.com';auxstaging = host: 'staging1.example.com' host: 'staging2.example.com' host: 'staging3.example.com'; // optional callback with args: ({Error}, {Array})aux; aux;// if callback is provided, it is called when all servers have responded, with// args: ({Error}, {Array})aux;
Usage example
As a contrived example, say we want enable the happy user, Fred, restart nginx on our Ubuntu server
- First we add Fred's public authentication key to our server
aux --user fred --add-key "ssh-rsa AAAA...=="
- Next we allow Fred to restart any service on the system
aux --user fred --add-command "sudo service \w+ restart"
- Create a simple script for Fred to use on his machine
var aux = ; var server = host: 'example.com';;
Now Fred can simply call this script to restart nginx on the server.
node restart_nginx.js
Examples
var aux = ; var host1 = host: 'host1.example.com';var host2 = host: 'host2.example.com' user: 'another_user';var host3 = host: 'host3.example.com';var host3 = host: 'host3.example.com'; var remote = host4;var realm1 = host1 host2 host3;var realm2 = remote host3;var realm3 = realm1 realm2; ;;
Remotes are streamable
var aux = ; var server1 = aux;var server2 = aux; ;