1.3.2 • Published 6 years ago

ssh2-client v1.3.2

Weekly downloads
165
License
MIT
Repository
github
Last release
6 years ago

ssh2-client

A Promise based wrapper around ssh2 to exec commands or setup a live shell on a remote host.

Install

npm i ssh2-client

Usage

  • Execute a command on a remote host : ssh.exec(HOST, command, options)
  • Open a live shell on a remote host : ssh.shell(HOST, options)

options is optional. options.ssh2 is forwarded to ssh2.

Examples

const ssh = require('ssh2-client');

const HOST = 'junk@localhost';

// Exec commands on remote host over ssh
ssh
  .exec(HOST, 'touch junk')
  .then(() => ssh.exec(HOST, 'ls -l junk'))
  .then(output => {
    const { out, error } = output;
    console.log(out);
    console.error(error);
  })
  .catch(err => console.error(err));

// Setup a live shell on remote host
ssh
  .shell(HOST)
  .then(() => console.log('Done'))
  .catch(err => console.error(err));

// Enable interactive password prompt
// askPassword option is only needed for the first command
const opts = {
  askPassword: true,
};

ssh
  .exec(HOST, 'touch junk', opts)
  .then(() => ssh.exec(HOST, 'ls -l junk'))
  .then(output => {
    const { out, error } = output;
    console.log(out);
    console.error(error);
  })
  .catch(err => console.error(err));
1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.2

6 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago