SSH shell is a util to manage shell commands variables and manage files upload/download. It has the same interface as local-shell to simplify usage.
Install via npm
npm i ssh-shell
Example of variable usage:
const SshShell = require('ssh-shell');
const shell = new SshShell({
username: 'user',
password: '********',
cwd: '/home/user',
});
shell.open()
.then(() => {
shell.set('NAME', 'World');
shell.exec('echo Hello $NAME')
.then(({code, io}) => {
if (code) {
throw new Error('Exit code is ' + code);
}
console.log(io.toString()); // -> Hello World
return shell.close();
});
});
Execute command and return promised Result object.
Added for compatibility with SshShell
Start session. Emit open
event.
Added for compatibility with SshShell
Stop session. Emit close
event.
Upload file from source to destination. Destination is resolving from cwd
value. If destination not set than it replaces with source's filename.
Upload data from buffer to the server.
Download file from source into destination. If destination not set than it replaces with source's filename.