ssh

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DialTimeout

func DialTimeout(network, addr string, config *ssh.ClientConfig, timeout time.Duration) (*ssh.Client, error)

Types

type Client

type Client struct {
	// User Authenticate as.
	User string `yaml:"user"`

	// Host SSH server to connect to.
	Host string `yaml:"host"`

	// Password Used for SSH authentication.
	Password string `yaml:"password,omitempty"`

	// PrivateKey Used for SSH authentication.
	PrivateKey string `yaml:"private_key,omitempty"`

	// Passphrase Private key passphrase.
	Passphrase string `yaml:"passphrase,omitempty"`

	// LogLevel Level of logging print.
	LogLevel int8 `yaml:"log_level,omitempty"`

	// LogEncoding Log output format.
	LogEncoding string `yaml:"log_encoding"`

	// RetryMin Minimum time to retry connecting to the ssh server
	RetryMin time.Duration `yaml:"retry_min,omitempty"`

	// RetryMax Maximum time to retry connecting to the ssh server
	RetryMax time.Duration `yaml:"retry_max,omitempty"`

	// ServerAliveInterval Interval to use for the ssh server's keepalive
	ServerAliveInterval time.Duration `yaml:"server_alive_interval"`

	// ServerAliveCountMax Maximum number of keepalive packets to send
	ServerAliveCountMax uint32 `yaml:"server_alive_count_max"`

	// Logger Used for logging
	Logger *slog.Logger
}

func (*Client) String

func (c *Client) String() string

func (*Client) Validate

func (c *Client) Validate() error

type Conn

type Conn struct {
	net.Conn
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
}

Conn wraps a net.Conn, and sets a deadline for every read and write operation.

func (*Conn) Read

func (c *Conn) Read(b []byte) (int, error)

func (*Conn) Write

func (c *Conn) Write(b []byte) (int, error)

type Ssh

type Ssh struct {
	Client *Client `yaml:"client"`

	Logger *slog.Logger
	// contains filtered or unexported fields
}

func New

func New(logger *slog.Logger, client *Client) *Ssh

func (*Ssh) DialContext

func (s *Ssh) DialContext(ctx context.Context, network string, address string) (net.Conn, error)

Jump to

Keyboard shortcuts

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