ssh~ SSHClient

SSHClient is a client for SSH servers. Internally client uses github.com/zmap/zgrab2/lib/ssh driver.

Constructor

new SSHClient()

Methods

Connect(host, port, username, password) → {boolean}

Connect tries to connect to provided host and port with provided username and password with ssh. Returns state of connection and error. If error is not nil, state will be false.
Parameters:
NameTypeDescription
hoststringThe host to connect to.
portnumberThe port to connect to.
usernamestringThe username to use for connection.
passwordstringThe password to use for connection.
Throws:
- The error encountered during connection.
Type
error
Returns:
- The state of the connection.
Type: 
boolean
Example
let m = require('nuclei/ssh');
let c = m.SSHClient();
let state = c.Connect('localhost', 22, 'user', 'password');

ConnectSSHInfoMode(host, port) → {HandshakeLog}

ConnectSSHInfoMode tries to connect to provided host and port. Returns HandshakeLog and error. If error is not nil, state will be false. HandshakeLog is a struct that contains information about the ssh connection.
Parameters:
NameTypeDescription
hoststringThe host to connect to.
portnumberThe port to connect to.
Throws:
- The error encountered during connection.
Type
error
Returns:
- The HandshakeLog object containing information about the ssh connection.
Type: 
HandshakeLog
Example
let m = require('nuclei/ssh');
let c = m.SSHClient();
let log = c.ConnectSSHInfoMode('localhost', 22);

ConnectWithKey(host, port, username, key) → {boolean}

ConnectWithKey tries to connect to provided host and port with provided username and private_key. Returns state of connection and error. If error is not nil, state will be false.
Parameters:
NameTypeDescription
hoststringThe host to connect to.
portnumberThe port to connect to.
usernamestringThe username to use for connection.
keystringThe private key to use for connection.
Throws:
- The error encountered during connection.
Type
error
Returns:
- The state of the connection.
Type: 
boolean
Example
let m = require('nuclei/ssh');
let c = m.SSHClient();
let state = c.ConnectWithKey('localhost', 22, 'user', 'key');