bassh

0.0.4 • Public • Published

bassh

Library for controlling machines through SSH

Install:

$ npm install bassh --save

Import:

import {Bassh} from 'bassh'

Instance

const bassh = Bassh({
    host: 'localhost',
    port: 22,
    username: 'user',
    password: 'pass' // or use privateKey for key-based authentication
})

Some possible settings

bassh.verbose = true // enable SSH stdout/stderr verbose mode

Run

bassh.onReady = async function(){
   console.log("bash ready")

	// Normal request
	let res = await bassh.cmd('echo ciao')
	console.log("bash res: ", res)

	// Real time output
	let pres = bassh.cmd('echo meow')
	
	pres.out = async (out)=>{
	   console.log("Real time stdout: ", out)
	}
	    
	pres.err = async (out)=>{
	   console.log("Real time stderr: ", out)
	}
	
	res = await pres;
	console.log("bash res: ", res)
}

Additional functions

bassh.inAppCmds(cmd, cmds)
async bassh.sudoSu(password, user='') // returns a classic cmd output, with wrongPassword = true if the password was wrong

Developed by

Riccardo Cecchini (@cekkr)

Readme

Keywords

Package Sidebar

Install

npm i bassh

Weekly Downloads

0

Version

0.0.4

License

MIT

Unpacked Size

9.42 kB

Total Files

7

Last publish

Collaborators

  • wizardink