@sumor/ssh-tools

1.0.5 • Public • Published

ssh-tools

SSH connections and tools that are simple, easy to use, and scalable.

CI Test Coverage Audit

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

Readme

Keywords

Package Sidebar

Install

npm i @sumor/ssh-tools

Homepage

sumor.cloud

Weekly Downloads

2,615

Version

1.0.5

License

MIT

Unpacked Size

16.5 kB

Total Files

13

Last publish

Collaborators

  • ohnow