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

ssh2-auth

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ssh2-auth

Wrapper over SSH2's client module to handle the authentication step

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

ssh2-auth

A wrapper over ssh2's client module to handle the authentication step.

Installation

npm install ssh2-auth

Usage

Simplest use case, just provide the hostname as a string, with user and port if they are not the default ones. In this example we are relying on the default user's public keys for the authentication (~/.ssh/id_dsa, ~/.ssh/id_ecdsa, ~/.ssh/id_rsa).

var ssh2auth = require('ssh2-auth');

ssh2auth('user@example.com:2222', function(err, conn) {
    if (err) return console.log(err);
    var command = 'echo hey there, im $(whoami) at $(hostname)';
    conn.exec(command, function(err, proc) {
        proc.stdout.pipe(process.stdout);
        proc.on('close', function() {
            conn.end();
        });
    });
});

Authentication with the provided password, for the current user and default port (port 22):

ssh2auth({ host: 'example.com', password: 'secret' }, function(err, conn) {
    if (err) return console.log(err);
    var command = 'echo hey there, im $(whoami) at $(hostname)';
    conn.exec(command, function(err, proc) {
        proc.stdout.pipe(process.stdout);
        proc.on('close', function() {
            conn.end();
        });
    });
});

Public key authentication with the identity file in a custom location:

ssh2auth({
    host: 'example.com',
    port: 'port',
    user: 'user',
    // can be an array of key paths instead, to try them until one of them succeeds
    privateKey: '/path/to/key.pem'
}, function(err, conn) {
    // ...
});

License

MIT license - http://www.opensource.org/licenses/mit-license.php

Keywords

ssh

FAQs

Package last updated on 06 May 2018

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