ssh

package
v3.1.7 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MIT, Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SSHClient

type SSHClient struct {
	Connection *ssh.Client
	// contains filtered or unexported fields
}

SSHClient is a client for SSH servers.

Internally client uses github.com/zmap/zgrab2/lib/ssh driver.

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

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

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

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

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

func (*SSHClient) SetTimeout added in v3.1.1

func (c *SSHClient) SetTimeout(sec int)

SetTimeout sets the timeout for the SSH connection in seconds

Jump to

Keyboard shortcuts

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