ossh

package
v0.2.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package ossh provides functionality for the SSH behaviours required by omnivore. These include both static and streaming ossh tasks, config generation, and similar abstractions of the https://github.com/discoriver/massh package.

Index

Constants

This section is empty.

Variables

View Source
var (
	KnownHostsFile string

	HostNotKnownErr    = errors.New("host is not known")
	HostKeyMismatchErr = errors.New("host is known, but has a mismatched key")
)
View Source
var (
	ErrHostAlreadyMoved          = errors.New("host cannot be moved, is already in a termination map")
	ErrHostIsNotInStreamCycle    = errors.New("host does not exist in StreamCycle")
	ErrStreamCycleNotInitialised = errors.New("StreamCycle is not initialised")
)

Functions

func GetKnownHosts

func GetKnownHosts() (ssh.HostKeyCallback, error)

KnownHosts returns host key callback from a custom known hosts path.

func GetKnownHostsPath

func GetKnownHostsPath() (string, error)

func GetSortedHostMapKeys

func GetSortedHostMapKeys(m map[string]struct{}) []string

Types

type OmniSSHConfig

type OmniSSHConfig struct {
	Config     *massh.Config
	StreamChan chan *massh.Result
}

func NewConfig

func NewConfig() *OmniSSHConfig

NewConfig initialises a new OmniSSHConfig

func (*OmniSSHConfig) AddAgent

func (c *OmniSSHConfig) AddAgent() error

AddAgent sets the SSH_AUTH_SOCK variable for auth in massh.Config.

func (*OmniSSHConfig) AddBastionHost

func (c *OmniSSHConfig) AddBastionHost(b string)

AddBastionHosts adds bastion host to massh.Config

func (*OmniSSHConfig) AddBastionHostConfig

func (c *OmniSSHConfig) AddBastionHostConfig(s *ssh.ClientConfig)

AddBastionHostConfig adds a custom ssh.ClientConfig for the bastion host.

func (*OmniSSHConfig) AddHostKeyCallback

func (c *OmniSSHConfig) AddHostKeyCallback(callback ssh.HostKeyCallback)

func (*OmniSSHConfig) AddHosts

func (c *OmniSSHConfig) AddHosts(h []string)

AddHosts populated OmniSSHConfig with target hosts.

func (*OmniSSHConfig) AddJob

func (c *OmniSSHConfig) AddJob(j *massh.Job)

AddJob adds a massh.Job to the OmniSSHConfig

func (*OmniSSHConfig) AddPasswordAuth

func (c *OmniSSHConfig) AddPasswordAuth(user string, password string)

AddPasswordAuth sets the user and password auth in massh.Config.

func (*OmniSSHConfig) AddPrivateKeyAuth

func (c *OmniSSHConfig) AddPrivateKeyAuth(keyPath string, password string) (err error)

AddPrivateKeyAuth configures the private key for auth in massh.Config. Returns error on failure.

func (*OmniSSHConfig) AddSSHConfig

func (c *OmniSSHConfig) AddSSHConfig(s *ssh.ClientConfig)

AddSSHConfig adds an ssh.ClientConfig to the OmniSSHConfig

func (*OmniSSHConfig) AddWorkerPool

func (c *OmniSSHConfig) AddWorkerPool(w int)

AddWorkerPool adds number of concurrent workers to config.

func (*OmniSSHConfig) Stream

func (c *OmniSSHConfig) Stream() (*StreamCycle, error)

Stream executes work contained in the massh.Config, and returns a StreamCycle for monitoring output and status.

type StreamCycle

type StreamCycle struct {
	HostsResultChan chan *massh.Result
	NumHostsInit    int
	Command         string

	// Lifecycle begin
	TodoHosts map[string]struct{}

	// Termination
	CompletedHosts map[string]struct{}
	FailedHosts    map[string]struct{}
	SlowHosts      map[string]struct{}
	AllHosts       []string
	// contains filtered or unexported fields
}

StreamCycle contains values for the lifecycle of a stream job. Hosts should begin their life in the TodoHosts map, and must be moved to one of the termination maps when the massh.Result.DoneChannel is written to. Hosts must not be moved back into the TodoHosts map once moved.

func (*StreamCycle) AddCompletedHost

func (s *StreamCycle) AddCompletedHost(host string) error

func (*StreamCycle) AddFailedHost

func (s *StreamCycle) AddFailedHost(host string) error

func (*StreamCycle) AddSlowHost

func (s *StreamCycle) AddSlowHost(host string) error

func (*StreamCycle) AddTodoHost

func (s *StreamCycle) AddTodoHost(host string) error

func (*StreamCycle) Initialise

func (s *StreamCycle) Initialise()

Initialise sets adds pending, completed, failed, and slow host pointers to a relevant map var for a specific StreamCycle.

func (*StreamCycle) TerminateSlowHosts

func (s *StreamCycle) TerminateSlowHosts() error

Jump to

Keyboard shortcuts

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