0.1.0 • Published 5 years ago
ssh-exec-async v0.1.0
ssh-exec-async
Execute a script/file over ssh using Node.JS and pipe to and from it
Install
$ yarn add ssh-exec-async
It is written in plain Javascript and uses ssh2 for all the heavy lifting.
Usage
const Client = require('ssh-exec-async')
// using ~/.ssh/id_rsa as the private key
const ssh = new Client('ubuntu@my-remote.com');
(async () => {
const res = await ssh.exec('ls -lh');
console.log(res);
const res2 = await ssh.execFile('test.sh');
console.log(res2);
})();
// or using the more settings
const ssh = new Client({
user: 'ubuntu',
host: 'my-remote.com',
password: 'my-user-password',
// key: myKeyFileOrBuffer,
});
(async () => {
const res = await ssh.exec('ls -lh');
console.log(res);
const res2 = await ssh.execFile('test.sh');
console.log(res2);
})();
The test.sh file content:
cd /data
pwd
ls -lh
License
MIT
0.1.0
5 years ago