ssh

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const TunnelPIDPlaceholder = "<ssh tunnel pid>"

Variables

View Source
var (
	ErrSSH              = errors.New("SSH failed")
	ErrAuthFailed       = fmt.Errorf("%w: authentication failed", ErrSSH)
	ErrConnectionFailed = fmt.Errorf("%w: connection failed", ErrSSH)
)
View Source
var PlainLocalhost = Destination{Host: "localhost"}

Functions

func ClassifyStderr added in v1.4.0

func ClassifyStderr(stderr string) error

ClassifyStderr inspects SSH stderr output and returns a typed error when a known failure pattern is detected, or nil if the output is unrecognised.

func ControlSocketPath

func ControlSocketPath(targetHost string) string

func ExecCmd

func ExecCmd(target Destination, command string, stdin []byte, sshArgs ...string) *exec.Cmd

ExecCmd builds a command to be executed on the target host. If the target is localhost, it will run locally when executed. Pass stdin data as optional parameter, or nil for no stdin.

func NewSSHTunnel

func NewSSHTunnel(targetDest Destination, port string, useControlSockets bool) (operation.Operation, operation.Operation, operation.Operation)

func ShellCommand

func ShellCommand(command string) string

func SplitUserHostPort

func SplitUserHostPort(raw string) (user, host, port string)

Types

type CheckSSHTunnelSecurity

type CheckSSHTunnelSecurity struct {
	TargetDest Destination
	Port       string
}

func NewCheckSSHTunnelSecurity

func NewCheckSSHTunnelSecurity(targetDest Destination, port string) *CheckSSHTunnelSecurity

func (*CheckSSHTunnelSecurity) Command

func (ct *CheckSSHTunnelSecurity) Command() *exec.Cmd

func (*CheckSSHTunnelSecurity) Description

func (ct *CheckSSHTunnelSecurity) Description() string

func (*CheckSSHTunnelSecurity) DryRun

func (ct *CheckSSHTunnelSecurity) DryRun(w io.Writer) error

func (*CheckSSHTunnelSecurity) Run

type Config added in v1.4.0

type Config struct {
	HostName string
	// contains filtered or unexported fields
}

func NewConfig added in v1.4.0

func NewConfig(dest Destination) Config

func NewConfigFromBytes added in v1.4.0

func NewConfigFromBytes(data []byte) Config

func (Config) ConnectTimeout added in v1.4.0

func (c Config) ConnectTimeout(fallback time.Duration) time.Duration

ConnectTimeout returns the user's configured ConnectTimeout if set, otherwise the fallback.

type Destination added in v1.4.0

type Destination struct {
	User string
	Host string
	Port string
}

func NewDestination added in v1.4.0

func NewDestination(destStr string) Destination

func (Destination) AsURI added in v1.4.0

func (d Destination) AsURI() string

func (Destination) IsLocalhost added in v1.4.0

func (d Destination) IsLocalhost() bool

func (Destination) IsPlainLocalhost added in v1.4.0

func (d Destination) IsPlainLocalhost() bool

func (Destination) Slugify added in v1.4.0

func (d Destination) Slugify() string

func (Destination) String added in v1.4.0

func (d Destination) String() string

type SSHTunnelProcessStop

type SSHTunnelProcessStop struct {
	Start *SSHTunnelStart
}

func NewSSHTunnelProcessStop

func NewSSHTunnelProcessStop(start *SSHTunnelStart) *SSHTunnelProcessStop

func (*SSHTunnelProcessStop) Command

func (s *SSHTunnelProcessStop) Command() *exec.Cmd

func (*SSHTunnelProcessStop) Description

func (s *SSHTunnelProcessStop) Description() string

func (*SSHTunnelProcessStop) DryRun

func (s *SSHTunnelProcessStop) DryRun(w io.Writer) error

func (*SSHTunnelProcessStop) Run

func (s *SSHTunnelProcessStop) Run(w io.Writer) error

type SSHTunnelStart

type SSHTunnelStart struct {
	TargetDest        Destination
	UseControlSockets bool
	Port              string
	Process           *os.Process
}

func NewSSHTunnelStart

func NewSSHTunnelStart(targetDest Destination, port string, useControlSockets bool) *SSHTunnelStart

func (*SSHTunnelStart) Command

func (s *SSHTunnelStart) Command() *exec.Cmd

func (*SSHTunnelStart) Description

func (s *SSHTunnelStart) Description() string

func (*SSHTunnelStart) DryRun

func (s *SSHTunnelStart) DryRun(w io.Writer) error

func (*SSHTunnelStart) Run

func (s *SSHTunnelStart) Run(w io.Writer) error

type SSHTunnelStop

type SSHTunnelStop struct {
	TargetDest Destination
}

func NewSSHTunnelStop

func NewSSHTunnelStop(targetDest Destination) *SSHTunnelStop

func (*SSHTunnelStop) Command

func (s *SSHTunnelStop) Command() *exec.Cmd

func (*SSHTunnelStop) Description

func (s *SSHTunnelStop) Description() string

func (*SSHTunnelStop) DryRun

func (s *SSHTunnelStop) DryRun(w io.Writer) error

func (*SSHTunnelStop) Run

func (s *SSHTunnelStop) Run(w io.Writer) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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