sshbulkcommander
v1.0.14
Published
An event driven SSH Bulk Command runner. With auto sudo and parallel processing.
Downloads
13
Readme
SSH Bulk Commander
An event based SSH bulk command runner with promise based request handler.
- Automatically handles sudo
- Returns array of objects listing commands which were run and associated responses.
- Run command to multiple ssh devices in parallel
If you need to connect to a bunch of devices via SSH and run any number of consecutive commands on them this tool is for you.
Code Example
Below is a basic code example :
import { SuperSSH, IConnectConfig } from "sshbulkcommander";
interface IResponse {
[key: string]: any;
// Array of devices commands must be run on.
const devices: Array<IConnectConfig> = [
{
host: '',
username: '',
port: 22,
password: '',
algorithms: {
serverHostKey: ['ssh-rsa', 'ssh-dss'],
cipher: ['aes256-cbc']
},
enableTTY:true
}
];
// Array of commands
const commands: Array<string> = [
'ls -lah',
'mkdir /nice'
];
// Include your device and commands arrays here.
const ssh = new SuperSSH({
devices,
commands
});
// Specify how many devices you would like to run commands on in parallel
ssh.parallelThreads = 2;
// Create your event listeners which will stream responses
ssh.on('processed', (data: IResponse) => {
console.log(data);
});
ssh.on('error', (data: IResponse) => {
console.log(data);
});
ssh.on('complete', data => {
console.log(data);
});
// Initialise your request via a promise.
ssh.request().catch(err => {
console.log(err);
});
If you have any questions or suggestions email me: [email protected]