ssh

package
v0.0.0-...-8fc2537 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeySetup  = "Setup"
	KeyConfig = "Config"
)
View Source
const Key = Namespace("ssh")

Key is a name of the plugin variable

Variables

This section is empty.

Functions

func Command

func Command(args ...force.Expression) (force.Action, error)

Command runs SSH command on a remote server

func Copy

func Copy(args ...interface{}) (force.Action, error)

Copy runs SSH command on a remote server

func ExecuteSCP

func ExecuteSCP(log force.Logger, client *ssh.Client, cmd scp.Command) error

ExecuteSCP runs remote scp command(shellCmd) on the remote server and runs local scp handler using SCP Command

func KeysEqual

func KeysEqual(ak, bk ssh.PublicKey) bool

KeysEqual is constant time compare of the keys to avoid timing attacks

func Scope

func Scope() (force.Group, error)

Scope returns a new scope with all the functions and structs defined, this is the entrypoint into plugin as far as force is concerned

func Session

func Session(hosts interface{}, actions ...Action) (force.Action, error)

Session groups sequence of commands together, if one fails, the chain stop execution

Types

type Action

type Action interface {
	BindClient(client *Client, env []Env) (Action, error)
	force.Action
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps ssh client and optional proxy client

func (*Client) Close

func (c *Client) Close() error

type CommandAction

type CommandAction struct {
	// contains filtered or unexported fields
}

func (*CommandAction) BindClient

func (s *CommandAction) BindClient(client *Client, env []Env) (Action, error)

func (*CommandAction) Eval

func (s *CommandAction) Eval(ctx force.ExecutionContext) (interface{}, error)

Eval evaluates variable and returns string

func (*CommandAction) MarshalCode

func (s *CommandAction) MarshalCode(ctx force.ExecutionContext) ([]byte, error)

MarshalCode marshals the action into code representation

func (*CommandAction) String

func (s *CommandAction) String() string

func (*CommandAction) Type

func (s *CommandAction) Type() interface{}

type Config

type Config struct {
	// User is a linux login to try
	User string
	// KnownHostsFile is a list of hosts or certificates
	KnownHostsFile string
	// KeyPairs is a list of key pairs
	KeyPairs []KeyPair
	// ProxyJump is a proxy jump address (similar to ssh -J)
	ProxyJump string
}

Config is an ssh client configuration

func (*Config) CheckAndSetDefaults

func (cfg *Config) CheckAndSetDefaults() (*ssh.ClientConfig, error)

CheckAndSetDefaults checks and sets default values

type CopyAction

type CopyAction struct {
	// contains filtered or unexported fields
}

func (*CopyAction) BindClient

func (s *CopyAction) BindClient(client *Client, _ []Env) (Action, error)

func (*CopyAction) Eval

func (s *CopyAction) Eval(ctx force.ExecutionContext) (interface{}, error)

func (*CopyAction) MarshalCode

func (s *CopyAction) MarshalCode(ctx force.ExecutionContext) ([]byte, error)

MarshalCode marshals the action into code representation

func (*CopyAction) String

func (s *CopyAction) String() string

func (*CopyAction) Type

func (s *CopyAction) Type() interface{}

type Dialer

type Dialer struct {
}

Dialer adds timeout to the SSH handshake

func (*Dialer) Dial

func (s *Dialer) Dial(network, addr string, config *ssh.ClientConfig) (*ssh.Client, error)

type Env

type Env struct {
	Key string
	Val string
}

type HostSequence

type HostSequence struct {
	// contains filtered or unexported fields
}

HostSequence executes a series of commands in a sequence

func (*HostSequence) Eval

func (s *HostSequence) Eval(ctx force.ExecutionContext) (interface{}, error)

Eval runs actions in sequence on a single host

func (*HostSequence) MarshalCode

func (p *HostSequence) MarshalCode(ctx force.ExecutionContext) ([]byte, error)

MarshalCode marshals action into code representation

func (*HostSequence) Type

func (s *HostSequence) Type() interface{}

Type returns type of the sequence

type Hosts

type Hosts struct {
	// Hosts is a list of hosts to target
	Hosts []string
	Env   []Env
	// ProxyJump is a proxy jump address (similar to ssh -J)
	ProxyJump string
}

Hosts enumerates hosts and helps to set environment

type KeyPair

type KeyPair struct {
	// PrivateKeyFile is a required path to SSH private key
	PrivateKeyFile string
	// CertFile is an optional path to certificate
	CertFile string
}

func (*KeyPair) Signer

func (k *KeyPair) Signer() (ssh.Signer, error)

type Namespace

type Namespace string

Namespace is a wrapper around string to namespace a variable in the context

type NewSession

type NewSession struct {
}

NewSession

func (*NewSession) NewInstance

func (n *NewSession) NewInstance(group force.Group) (force.Group, interface{})

NewInstance returns a new instance of a function with a new lexical scope

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

Plugin is a new logging plugin

type SessionAction

type SessionAction struct {
	// contains filtered or unexported fields
}

SessionAction runs actions in a sequence, if the action fails, next actions are not run

func (*SessionAction) Eval

func (s *SessionAction) Eval(ctx force.ExecutionContext) (interface{}, error)

Eval runs actions in sequence using the passed scope

func (*SessionAction) MarshalCode

func (p *SessionAction) MarshalCode(ctx force.ExecutionContext) ([]byte, error)

MarshalCode marshals action into code representation

func (*SessionAction) Type

func (s *SessionAction) Type() interface{}

type Setup

type Setup struct {
	// contains filtered or unexported fields
}

Setup creates new instances of plugins

func (*Setup) Eval

func (n *Setup) Eval(ctx force.ExecutionContext) (interface{}, error)

Eval sets up logging plugin for the instance group

func (*Setup) MarshalCode

func (n *Setup) MarshalCode(ctx force.ExecutionContext) ([]byte, error)

MarshalCode marshals plugin setup to code

func (*Setup) NewInstance

func (n *Setup) NewInstance(group force.Group) (force.Group, interface{})

NewInstance returns a new instance of a plugin bound to group

func (*Setup) Type

func (n *Setup) Type() interface{}

type Target

type Target struct {
	Local bool
	Path  force.StringVar
}

func Local

func Local(path force.StringVar) Target

func Remote

func Remote(path force.StringVar) Target

Directories

Path Synopsis
Package scp handles file uploads and downloads via scp command
Package scp handles file uploads and downloads via scp command

Jump to

Keyboard shortcuts

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