ssh

package
v0.0.0-...-183c8bc Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadServerKeyMsg     = "server key for given host differs from key in known_host"
	ErrUnknownServerKeyMsg = "server key not found in known_hosts"
)

Functions

func NewSSHClientConfig

func NewSSHClientConfig(url *urlPkg.URL, credentialsConfig Config) (*ssh.ClientConfig, error)

Types

type Config

type Config struct {
	Identity           string
	PassPhrase         string
	PasswordCallback   PasswordCallback
	PassPhraseCallback PassPhraseCallback
	HostKeyCallback    HostKeyCallback
}

type ContextDialer

type ContextDialer interface {
	DialContext(ctx context.Context, network, address string) (net.Conn, error)
}

func NewDialContext

func NewDialContext(url *urlPkg.URL, config Config) (ContextDialer, string, error)

NewDialContext allows access to docker daemon in a remote machine using SSH.

It creates a new ContextDialer which dials docker daemon in the remote and also returns Docker Host URI as seen by the remote.

Knowing the Docker Host is useful when mounting docker socket into a container.

Dialing the remote docker daemon can be done in two ways:

- Use SSH to tunnel Unix/TCP socket.

- Use SSH to execute the "docker system dial-stdio" command in the remote and forward its stdio.

The tunnel method is used whenever possible. The "stdio" method is used as a fallback when tunneling is not possible: e.g. when remote uses Windows' named pipe.

When tunneling is used all connection dialed by the returned ContextDialer are tunneled via single SSH connection. The connection should be disposed when dialer is no longer needed.

For this reason returned ContextDialer may also implement io.Closer. Caller of this function should check if the returned ContextDialer is also an instance of io.Closer and call Close() on it if it is.

type DialContextFn

type DialContextFn = func(ctx context.Context, network, addr string) (net.Conn, error)

type HostKeyCallback

type HostKeyCallback func(hostPort string, pubKey ssh.PublicKey) error

func NewHostKeyCbk

func NewHostKeyCbk() HostKeyCallback

type PassPhraseCallback

type PassPhraseCallback func() (string, error)

func NewPassPhraseCbk

func NewPassPhraseCbk() PassPhraseCallback

type PasswordCallback

type PasswordCallback func() (string, error)

func NewPasswordCbk

func NewPasswordCbk() PasswordCallback

Jump to

Keyboard shortcuts

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