1.0.1 • Published 4 years ago

ssh2-promisify v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

SSH2-Promisify

SSH2-Promisify is a wrapper around ssh2. It support all the features of ssh2 package in addition with other functions which return result in a promisify manner. The main purpose of this package is to execute multiple commands at different stages in an interactive mode using a single shell session. This can be achieved by calling exec() function multiple time in your code when ever you want to execute a single command or a block of commands.

Getting Started

Prerequisites

  1. Install Node

Installing

npm i ssh2-promisify

Usage

const SSH2Promisify = require('./ssh')
const express = require('express')
const app = express()
const port = 3000

app.listen(port, () => console.log(`SSH2-Promisify app listening at http://localhost:${port}`))
app.get('/', async (req, res) => {

    const ssh2Promisify = new SSH2Promisify()
    
    ssh2Promisify.connect({
      host: '',
      port: 22,
      username: '',
      password: ''
    })

    const session = await ssh2Promisify.startSession(ssh2Promisify)

    const result1 = await ssh2Promisify.exec(session, command1)
    console.log(result1)

    const result2 = await ssh2Promisify.exec(session, command2)
    console.log(result2)

    ssh2Promisify.endSession(ssh2Promisify)
    
    const Response = {
      ResponseCode: '000',
      ResponseStatus: 'SUCCESS',
      Response: {
        result1: result1,
        result2: result2
      }
    }

    res.status(200).send(Response)
})

Author

  • Arslan Fareed
1.0.1

4 years ago

1.0.0

4 years ago