remotessh

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2019 License: Apache-2.0 Imports: 29 Imported by: 37

Documentation

Index

Constants

View Source
const MaxNumberOfSSHConnections = 15

MaxNumberOfSSHConnections defines the max number of ssh connections to each ssh remote device that can be used to run commands concurrently.

Variables

This section is empty.

Functions

func Devices

func Devices(ctx context.Context, configuration []io.ReadCloser) ([]bind.Device, error)

Devices returns the list of attached ssh devices.

func Monitor added in v1.4.0

func Monitor(ctx context.Context, r *bind.Registry, interval time.Duration, conf func() ([]io.ReadCloser, error)) error

Monitor updates the registry with devices that are added and removed at the specified interval. Monitor returns once the context is cancelled.

Types

type Configuration

type Configuration struct {
	// The name to use for this connection
	Name string
	// The hostname to connect to
	Host string `json:"host"`
	// User is the username to use for login
	User string `json:"user"`
	// Which port should be used
	Port uint16 `json:"port,string"`
	// The pem encoded public key file to use for the connection.
	// If not specified uses ~/.ssh/id_rsa
	Keyfile string `json:"keyPath"`
	// The known_hosts file to use for authentication. Defaults to
	// ~/.ssh/known_hosts
	KnownHosts string `json:"knownHostsPath"`
	// Environment variables to set on the connection
	Env []string
}

Configuration represents a configuration for connecting to an SSH remote client. The SSH agent is first used to attempt connection, followed by the given Keyfile

func ReadConfigurations

func ReadConfigurations(r io.Reader) ([]Configuration, error)

ReadConfigurations reads a set of configurations from then given reader, and returns the configurations to the user.

type Device

type Device interface {
	bind.Device
	// PushFile will transfer the local file at sourcePath to the remote
	// machine at destPath
	PushFile(ctx context.Context, sourcePath, destPath string) error
	// PullFile will transfer the remote file at sourcePath to the local
	// machine at destPath
	PullFile(ctx context.Context, sourcePath, destPath string) error
	// MakeTempDir makes a temporary directory, and returns the
	// path, as well as a function to call to clean it up.
	MakeTempDir(ctx context.Context) (string, app.Cleanup, error)
	// WriteFile writes the given file into the given location on the remote device
	WriteFile(ctx context.Context, contents io.Reader, mode os.FileMode, destPath string) error

	// GetFilePermissions gets the unix permissions for the remote file
	GetFilePermissions(ctx context.Context, path string) (os.FileMode, error)
	// DefaultReplayCacheDir returns the default path for replay resource caches
	DefaultReplayCacheDir() string
}

Device extends the bind.Device interface with capabilities specific to remote SSH clients

func GetConnectedDevice

func GetConnectedDevice(ctx context.Context, c Configuration) (Device, error)

GetConnectedDevice returns a device that matches the given configuration.

Jump to

Keyboard shortcuts

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