@sumor/ssh-tools
v1.0.5
Published
SSH connections and tools that are simple, easy to use, and scalable.
Downloads
8,253
Readme
ssh-tools
SSH connections and tools that are simple, easy to use, and scalable.
Installation
npm install ssh-tools --save
Prerequisites
Node.JS version
Require Node.JS version 18.x or above
Usage
SSH Connection
const SSH = require('@sumor/ssh-tools');
const ssh = SSH({
// fake server details, replace with your own
"host": "62.16.12.88",
"iHost": "172.11.200.330",
"port": 22,
"username": "root",
"password": "password"
});
await ssh.connect();
await ssh.disconnect();
SSH Command
const SSH = require('@sumor/ssh-tools');
const ssh = SSH(server);
await ssh.connect();
try {
const result = await ssh.exec('ls -la');
console.log(result);
await ssh.disconnect();
} catch (error) {
await ssh.disconnect(); // don't forget to disconnect if error occurs
throw(error);
}
More examples
Please check the Unit Test