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:
Name | Type | Description |
---|---|---|
host | string | The host to connect to. |
port | number | The port to connect to. |
username | string | The username to use for connection. |
password | string | The password to use for connection. |
- Source
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:
Name | Type | Description |
---|---|---|
host | string | The host to connect to. |
port | number | The port to connect to. |
- Source
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:
Name | Type | Description |
---|---|---|
host | string | The host to connect to. |
port | number | The port to connect to. |
username | string | The username to use for connection. |
key | string | The private key to use for connection. |
- Source
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');