bassh
v0.0.4
Published
Library for handle SSH commands to bash
Downloads
2
Readme
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)