sshexecutor

package
v0.0.0-...-288f078 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: AGPL-3.0, Apache-2.0, CC-BY-SA-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package sshexecutor provides an implementation of pool.Executor using a long-lived multiplexed SSH session.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoAddress = errors.New("instance has no address")

Functions

This section is empty.

Types

type Executor

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

An Executor uses a multiplexed SSH connection to execute shell commands on a remote target. It reconnects automatically after errors.

When setting up a connection, the Executor accepts whatever host key is provided by the remote server, then passes the received key and the SSH connection to the target's VerifyHostKey method before executing commands on the connection.

A zero Executor must not be used before calling SetTarget.

An Executor must not be copied.

func New

New returns a new Executor, using the given target.

func (*Executor) Close

func (exr *Executor) Close()

Close shuts down any active connections.

func (*Executor) Execute

func (exr *Executor) Execute(env map[string]string, cmd string, stdin io.Reader) ([]byte, []byte, error)

Execute runs cmd on the target. If an existing connection is not usable, it sets up a new connection to the current target.

func (*Executor) SetSigners

func (exr *Executor) SetSigners(signers ...ssh.Signer)

SetSigners updates the set of private keys that will be offered to the target next time the Executor sets up a new connection.

func (*Executor) SetTarget

func (exr *Executor) SetTarget(t cloud.ExecutorTarget)

SetTarget sets the current target. The new target will be used next time a new connection is set up; until then, the Executor will continue to use the existing target.

The new target is assumed to represent the same host as the previous target, although its address and host key might differ.

func (*Executor) SetTargetPort

func (exr *Executor) SetTargetPort(port string)

SetTargetPort sets the default port (name or number) to connect to. This is used only when the address returned by the target's Address() method does not specify a port. If the given port is empty (or SetTargetPort is not called at all), the default port is "ssh".

func (*Executor) Target

func (exr *Executor) Target() cloud.ExecutorTarget

Target returns the current target.

func (*Executor) TargetHostPort

func (exr *Executor) TargetHostPort() (string, string)

Jump to

Keyboard shortcuts

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