@sumor/ssh-tools

1.0.7 • 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

60,903

Version

1.0.7

License

MIT

Unpacked Size

17 kB

Total Files

14

Last publish

Collaborators

  • ohnow