Help us shape the future of Go! Take the 2026 Go Developer Survey

ssh

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Serves the interactive SSH authentication WebSocket, whose prompt establishes a control master. It runs commands only through Runner and has no view of the session domain. The request that first sees the master turn healthy owns it, so shutdown reaps that exact process.

Package ssh runs bounded remote commands and foreground OpenSSH control masters against per-principal configs. Every operation resolves the alias first; that output also identifies its control socket. Interactive masters disable ControlPersist because persistence backgrounds authentication. Exit status 255 belongs to ssh itself and cannot establish whether a remote command ran; aliases trust literal Host lines in process-owned configs. FirstHop follows each ProxyJump entry as the ssh:// URI it is, so `ssh -G` resolves its user, host and port.

Marker-delimited output is the shared envelope for discovery, scheduler reconciliation, and remote log tails. Each section name occupies a line of its own so SSH banner noise remains outside the framed response. The SSH host is untrusted: an out-of-order, missing, duplicate, or unknown marker rejects the whole response rather than allowing one protocol to interpret another's output.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidAlias = security.New("invalid_ssh_alias", "invalid SSH alias", http.StatusBadRequest)

Functions

func AmbiguousExit

func AmbiguousExit(err error) bool

func AuthenticationFailure

func AuthenticationFailure(message string) bool

func ClassifyFailure

func ClassifyFailure(alias, stderr string, err error) error

func FailureMessage

func FailureMessage(stderr string, err error) string

func Sections

func Sections(output, prefix string, names []string) (map[string]string, error)

func ShellQuote

func ShellQuote(value string) string

func ValidAlias

func ValidAlias(value string) bool

Types

type ClientFrame

type ClientFrame struct {
	Type string `json:"type"`
	Cols uint16 `json:"cols,omitempty"`
	Rows uint16 `json:"rows,omitempty"`
}

type Configurations

type Configurations struct {
	Dir      string
	Template Runner
}

func (Configurations) ConfigPath

func (c Configurations) ConfigPath(principal security.Principal) string

func (Configurations) Runner

func (c Configurations) Runner(principal security.Principal) Runner

type ControlManager

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

func NewControlManager

func NewControlManager() *ControlManager

func (*ControlManager) Close

func (m *ControlManager) Close()

func (*ControlManager) ServeWebSocket

func (m *ControlManager) ServeWebSocket(writer http.ResponseWriter, request *http.Request, alias string, runner Runner)

type PrivateKeyMetadata

type PrivateKeyMetadata struct {
	Type        string
	Fingerprint string
}

func InspectPrivateKey

func InspectPrivateKey(private []byte) (PrivateKeyMetadata, error)

type Runner

type Runner struct {
	SSHBin           string
	Timeout          time.Duration
	ControlNamespace string
	ConfigPath       string
}

func (Runner) EffectiveTimeout

func (r Runner) EffectiveTimeout() time.Duration

func (Runner) FirstHop

func (r Runner) FirstHop(ctx context.Context, alias string) (string, error)

func (Runner) Run

func (r Runner) Run(ctx context.Context, alias string, stdin io.Reader, remoteArgs ...string) (string, error)

func (Runner) RunOutput

func (r Runner) RunOutput(ctx context.Context, alias string, stdin io.Reader, remoteArgs ...string) (string, string, error)

type ServerFrame

type ServerFrame struct {
	Type    string `json:"type"`
	Code    *int   `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

Jump to

Keyboard shortcuts

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