ssh

package
v3.3.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2024 License: MIT, Apache-2.0 Imports: 7 Imported by: 1

Documentation

Overview

Warning - This is generated code

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SSHClient

type SSHClient struct {
	// contains filtered or unexported fields
}

SSHClient is a client for SSH servers. Internally client uses github.com/zmap/zgrab2/lib/ssh driver. @example ```javascript const ssh = require('nuclei/ssh'); const client = new ssh.SSHClient(); ```

func (*SSHClient) Close added in v3.1.0

func (c *SSHClient) Close() (bool, error)

Close closes the SSH connection and destroys the client Returns the success state and error. If error is not nil, state will be false @example ```javascript const ssh = require('nuclei/ssh'); const client = new ssh.SSHClient(); client.Connect('acme.com', 22, 'username', 'password'); const closed = client.Close(); ```

func (*SSHClient) Connect

func (c *SSHClient) Connect(host string, port int, username, password string) (bool, error)

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 @example ```javascript const ssh = require('nuclei/ssh'); const client = new ssh.SSHClient(); const connected = client.Connect('acme.com', 22, 'username', 'password'); ```

func (*SSHClient) ConnectSSHInfoMode

func (c *SSHClient) ConnectSSHInfoMode(host string, port int) (*ssh.HandshakeLog, error)

ConnectSSHInfoMode tries to connect to provided host and port with 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 @example ```javascript const ssh = require('nuclei/ssh'); const client = new ssh.SSHClient(); const info = client.ConnectSSHInfoMode('acme.com', 22); log(to_json(info)); ```

func (*SSHClient) ConnectWithKey

func (c *SSHClient) ConnectWithKey(host string, port int, username, key string) (bool, error)

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 @example ```javascript const ssh = require('nuclei/ssh'); const client = new ssh.SSHClient(); const privateKey = `-----BEGIN RSA PRIVATE KEY----- ...`; const connected = client.ConnectWithKey('acme.com', 22, 'username', privateKey); ```

func (*SSHClient) Run added in v3.1.0

func (c *SSHClient) Run(cmd string) (string, error)

Run tries to open a new SSH session, then tries to execute the provided command in said session Returns string and error. If error is not nil, state will be false The string contains the command output @example ```javascript const ssh = require('nuclei/ssh'); const client = new ssh.SSHClient(); client.Connect('acme.com', 22, 'username', 'password'); const output = client.Run('id'); log(output); ```

func (*SSHClient) SetTimeout added in v3.1.1

func (c *SSHClient) SetTimeout(sec int)

SetTimeout sets the timeout for the SSH connection in seconds @example ```javascript const ssh = require('nuclei/ssh'); const client = new ssh.SSHClient(); client.SetTimeout(10); ```

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL