ssh

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Overview

Package ssh is a transport.Interface implementation, which forwards given addresses over specified SSH host.

Index

Constants

View Source
const (
	// User is a default user used for SSH connections.
	User = "root"

	// ConnectionTimeout is a default time SSH will wait while connecting to unreachable server.
	ConnectionTimeout = "30s"

	// RetryTimeout is a default time after we give up connecting to unreachable server.
	RetryTimeout = "60s"

	// RetryInterval is a default time how long we wait between SSH connection attempts.
	RetryInterval = "1s"

	// Port is a default port used for SSH connections.
	Port = 22
)
View Source
const (
	// SSHAuthSockEnv is environment variable name used for connecting to ssh-agent.
	SSHAuthSockEnv = "SSH_AUTH_SOCK"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Address is a hostname or IP address which should be used for connection.
	Address string `json:"address,omitempty"`

	// Port defines which port should be used for SSH connection.
	Port int `json:"port,omitempty"`

	// User defines as which user the connection should authenticate.
	User string `json:"user,omitempty"`

	// Password adds password as one of available authentication methods.
	Password string `json:"password,omitempty"`

	// ConnectionTimeout defines time, after which SSH client gives up single attempt for connecting.
	ConnectionTimeout string `json:"connectionTimeout,omitempty"`

	// RetryTimeout defines after what time connecting should give up, if trying to connect to unreachable
	// host.
	RetryTimeout string `json:"retryTimeout,omitempty"`

	// RetryInterval defines how long to wait between connection attempts.
	RetryInterval string `json:"retryInterval,omitempty"`

	// PrivateKey adds private key as authentication method.
	// It must be defined as valid SSH private key in PEM format.
	PrivateKey string `json:"privateKey,omitempty"`

	Dialer func(network, address string, config *gossh.ClientConfig) (Dialer, error) `json:"-"`
}

Config represents SSH transport configuration.

All fields are required. Use BuildConfig to pre-fill the configuration with default values.

func BuildConfig

func BuildConfig(sshConfig, defaults *Config) *Config

BuildConfig takes destination SSH configuration, struct with default values provided by the user and merges it together with global SSH default values.

func (*Config) New

func (d *Config) New() (transport.Interface, error)

New validates SSH configuration and returns new instance of transport interface.

func (*Config) Validate

func (d *Config) Validate() error

Validate validates given configuration.

type Dialer added in v0.8.0

type Dialer interface {
	Dial(network, address string) (net.Conn, error)
}

Dialer represents expected functionality from constructed SSH client.

Jump to

Keyboard shortcuts

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