New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

egg-ssh

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-ssh

egg 插件 基于ssh2

latest
Source
npmnpm
Version
1.0.5
Version published
Maintainers
1
Created
Source

egg-ssh

NPM version npm download

一款基于node-ssh,它基于ssh2的egg链接ssh的插件。 主要api参考node-ssh

拓展API


class EggSSH extends NodeSSH{
    
    constructor(config:Config)

    // 自动连接
    autoConnect(config?:Config):Promise<EggSSH>
    
    // 自动连接并执行命令
    autoConnectExecCommand(givenCommand: string,
        options?:SSHExecCommandOptions,
        config?:Config):Promise<SSHExecCommandResponse>
}

Install

$ npm i egg-ssh --save

Usage

// {app_root}/config/plugin.js
exports.ssh = {
  enable: true,
  package: 'egg-ssh',
};

Configuration

链接配置参考 node-ssh

// {app_root}/config/config.default.js
exports.ssh =  {
    host: '127.0.0.1',
    port: '22',
    username: 'root',
    password: 'root',
};

see config/config.default.js for more detail.

Example

ssh 会挂载到app上,可以通过this.app.ssh进行api调用

// 例如
// app/controller/home.js
'use strict';

const Controller = require('egg').Controller;

class HomeController extends Controller {
  async index() {
    const result = await this.app.ssh.autoConnectExecCommand('expr 1 + 1');
    this.ctx.body = result.stdout;
  }
}

module.exports = HomeController;

Questions & Suggestions

Please open an issue here.

License

MIT

Keywords

egg

FAQs

Package last updated on 07 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts