> ## Documentation Index
> Fetch the complete documentation index at: https://projectdiscovery-subfinder-reference-blog.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Ssh

<a name="module_ssh" />

## ssh

* [ssh](#module_ssh)
  * [`SSHClient`](#module_ssh..SSHClient)
    * [`.Close()`](#module_ssh..SSHClient+Close) ⇒ <code>boolean</code>
    * [`.Connect(host, port, username, password)`](#module_ssh..SSHClient+Connect) ⇒ <code>boolean</code>
    * [`.ConnectSSHInfoMode(host, port)`](#module_ssh..SSHClient+ConnectSSHInfoMode) ⇒ <code>HandshakeLog</code>
    * [`.ConnectWithKey(host, port, username, key)`](#module_ssh..SSHClient+ConnectWithKey) ⇒ <code>boolean</code>
    * [`.Run(cmd)`](#module_ssh..SSHClient+Run) ⇒ <code>string</code>
    * [`.SetTimeout(sec)`](#module_ssh..SSHClient+SetTimeout)
  * [`HandshakeLog`](#module_ssh..HandshakeLog) : <code>object</code>

<a name="module_ssh..SSHClient" />

### (ssh).SSHClient

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

**Kind**: inner class of [<code>ssh</code>](#module_ssh)

* [`SSHClient`](#module_ssh..SSHClient)
  * [`.Close()`](#module_ssh..SSHClient+Close) ⇒ <code>boolean</code>
  * [`.Connect(host, port, username, password)`](#module_ssh..SSHClient+Connect) ⇒ <code>boolean</code>
  * [`.ConnectSSHInfoMode(host, port)`](#module_ssh..SSHClient+ConnectSSHInfoMode) ⇒ <code>HandshakeLog</code>
  * [`.ConnectWithKey(host, port, username, key)`](#module_ssh..SSHClient+ConnectWithKey) ⇒ <code>boolean</code>
  * [`.Run(cmd)`](#module_ssh..SSHClient+Run) ⇒ <code>string</code>
  * [`.SetTimeout(sec)`](#module_ssh..SSHClient+SetTimeout)

<a name="module_ssh..SSHClient+Close" />

#### sshClient.Close() ⇒ <code>boolean</code>

Close closes the SSH connection and destroys the client

**Kind**: instance method of [<code>SSHClient</code>](#module_ssh..SSHClient)\
**Returns**: <code>boolean</code> - - The success state of the operation.\
**Throws**:

* <code>error</code> - The error encountered during the operation.

**Example**

```js
let m = require('nuclei/ssh');
    let c = m.SSHClient();
    let state = c.Connect('localhost', 22, 'user', 'password');
    let result = c.Close();
```

<a name="module_ssh..SSHClient+Connect" />

#### sshClient.Connect(host, port, username, password) ⇒ <code>boolean</code>

Connect tries to connect to provided host and port with provided username and password with ssh.

**Kind**: instance method of [<code>SSHClient</code>](#module_ssh..SSHClient)\
**Returns**: <code>boolean</code> - - The success state of the operation.\
**Throws**:

* <code>error</code> - The error encountered during the operation.

| Param    | Type                | Description                      |
| -------- | ------------------- | -------------------------------- |
| host     | <code>string</code> | The host to connect to.          |
| port     | <code>number</code> | The port to connect to.          |
| username | <code>string</code> | The username for the connection. |
| password | <code>string</code> | The password for the connection. |

**Example**

```js
let m = require('nuclei/ssh');
    let c = m.SSHClient();
    let result = c.Connect('localhost', 22, 'user', 'password');
```

<a name="module_ssh..SSHClient+ConnectSSHInfoMode" />

#### sshClient.ConnectSSHInfoMode(host, port) ⇒ <code>HandshakeLog</code>

ConnectSSHInfoMode tries to connect to provided host and port with provided host and port

**Kind**: instance method of [<code>SSHClient</code>](#module_ssh..SSHClient)\
**Returns**: <code>HandshakeLog</code> - - The HandshakeLog object containing information about the ssh connection.\
**Throws**:

* <code>error</code> - The error encountered during the operation.

| Param | Type                | Description             |
| ----- | ------------------- | ----------------------- |
| host  | <code>string</code> | The host to connect to. |
| port  | <code>number</code> | The port to connect to. |

**Example**

```js
let m = require('nuclei/ssh');
    let c = m.SSHClient();
    let result = c.ConnectSSHInfoMode('localhost', 22);
```

<a name="module_ssh..SSHClient+ConnectWithKey" />

#### sshClient.ConnectWithKey(host, port, username, key) ⇒ <code>boolean</code>

ConnectWithKey tries to connect to provided host and port with provided username and private\_key.

**Kind**: instance method of [<code>SSHClient</code>](#module_ssh..SSHClient)\
**Returns**: <code>boolean</code> - - The success state of the operation.\
**Throws**:

* <code>error</code> - The error encountered during the operation.

| Param    | Type                | Description                         |
| -------- | ------------------- | ----------------------------------- |
| host     | <code>string</code> | The host to connect to.             |
| port     | <code>number</code> | The port to connect to.             |
| username | <code>string</code> | The username for the connection.    |
| key      | <code>string</code> | The private key for the connection. |

**Example**

```js
let m = require('nuclei/ssh');
    let c = m.SSHClient();
    let result = c.ConnectWithKey('localhost', 22, 'user', 'key');
```

<a name="module_ssh..SSHClient+Run" />

#### sshClient.Run(cmd) ⇒ <code>string</code>

Run tries to open a new SSH session, then tries to execute the provided command in said session

**Kind**: instance method of [<code>SSHClient</code>](#module_ssh..SSHClient)\
**Returns**: <code>string</code> - - The output of the command.\
**Throws**:

* <code>error</code> - The error encountered during the operation.

| Param | Type                | Description             |
| ----- | ------------------- | ----------------------- |
| cmd   | <code>string</code> | The command to execute. |

**Example**

```js
let m = require('nuclei/ssh');
    let c = m.SSHClient();
    let result = c.Run('ls');
```

<a name="module_ssh..SSHClient+SetTimeout" />

#### sshClient.SetTimeout(sec)

SetTimeout sets the timeout for the SSH connection in seconds

**Kind**: instance method of [<code>SSHClient</code>](#module_ssh..SSHClient)

| Param | Type                | Description                            |
| ----- | ------------------- | -------------------------------------- |
| sec   | <code>number</code> | The number of seconds for the timeout. |

**Example**

```js
let m = require('nuclei/ssh');
    let c = m.SSHClient();
    c.SetTimeout(30);
```

<a name="module_ssh..HandshakeLog" />

### (ssh).HandshakeLog : <code>object</code>

HandshakeLog is a struct that contains information about the ssh connection.

**Kind**: inner typedef of [<code>ssh</code>](#module_ssh)
