ssh

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddKnownHost

func AddKnownHost(host string, remote net.Addr, key ssh.PublicKey) error

func IsConnBroken added in v0.5.1

func IsConnBroken(err error) bool

IsConnBroken reports whether err indicates the underlying SSH transport is dead (as opposed to a command-level failure). Long migrations open thousands of sessions against the same connection; the target sshd, a network blip or an idle-timeout can tear the transport down mid-run. When that happens every later session/command fails until the connection is rebuilt, so these errors must trigger a reconnect rather than a plain retry.

Network-layer failures are matched against real error values via errors.Is/As (io.EOF, net.ErrClosed, the syscall errnos, the net.Error timeout interface), which is robust to wrapping. golang.org/x/crypto/ssh reports many channel- and session-level transport failures as plain unwrapped strings, so a lower-cased substring check is kept as a fallback for those.

Types

type Client

type Client struct {
	*goph.Client
	SSHTarget *model.SSHTarget
	// contains filtered or unexported fields
}

func NewSSHClient

func NewSSHClient(connectionType ConnectionType, id string, nsID string, infraID string) (*Client, error)

func (*Client) Close added in v0.5.0

func (c *Client) Close() error

func (*Client) NewSessionWithRetry added in v0.3.1

func (c *Client) NewSessionWithRetry() (*ssh.Session, error)

func (*Client) RunWithRetry added in v0.5.1

func (c *Client) RunWithRetry(cmd string) ([]byte, error)

RunWithRetry runs cmd on the host and returns its combined output. Unlike the embedded goph Run, it rebuilds the connection and retries when the transport dies mid-run, so a single reset does not cascade into every remaining step.

type ConnectionType added in v0.2.1

type ConnectionType int
const (
	ConnectionTypeSource ConnectionType = iota
	ConnectionTypeTarget
)

Jump to

Keyboard shortcuts

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