1.1.0 • Published 11 months ago

nodejs-ssh2 v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Node-SSH2 Extends Node-SSH

Installing

npm i nodejs-ssh2

or

yarn add nodejs-ssh2

Example

import { ClientSSH } from 'nodejs-ssh2';

const ssh = new ClientSSH();

await ssh.connect({
  host: 'localhost',
  username: 'ubuntu',
  password: '123'
});

await ssh.execCommand(`
    ls -la
    `, {
        onStderr: (chunk) => console.log(chunk.toString('utf8')),
        onStdout: (chunk) => console.log(chunk.toString('utf8'))
    });

await ssh.dispose();

Keyboard-interactive user authentication

In some cases you have to enable keyboard-interactive user authentication. Otherwise you will get an All configured authentication methods failed error.

Ubuntu server 22.04 LTS

Open file

sudo nano /etc/ssh/sshd_config

Add the line below

PubkeyAcceptedKeyTypes=+ssh-rsa

Restart the service sshd

sudo systemctl restart sshd.service

Example:

import { ClientSSH } from 'nodejs-ssh2';

const ssh = new ClientSSH();

await ssh.connect({
        host: SSH_HOST ?? 'host',
        username: SSH_USERNAME ?? 'username',
        tryKeyboard: true,
        privateKey: `-----BEGIN OPENSSH PRIVATE KEY-----
...
-----END OPENSSH PRIVATE KEY-----
`
    });

await ssh.dispose();

License

This project is licensed under the terms of MIT license. See the LICENSE file for more info.

1.1.0

11 months ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago