ssh

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 26 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ssh implements the SSH-pipe CLI surface. Every session must offer a publickey; the key's SHA256 fingerprint is the identity the application services use for quota accounting and ownership checks.

Index

Constants

View Source
const (
	ExitOK       = 0 // success
	ExitErr      = 1 // generic / unclassified failure
	ExitUsage    = 2 // malformed args, bad verb, parser failure
	ExitAuth     = 3 // identity required (no key) or missing-owner service error
	ExitNotFound = 4 // not found, including owner-collapsed permission failures

	ExitSybilRefuse = 6 // Sybil per-subnet rate-limit refusal
)

Structured exit codes for SSH sessions, carried back to the local ssh client as the process exit code. Scripts branch on them, so the mapping is frozen: a value's meaning never changes, and a new meaning takes the next free slot. The source of truth; docs/SPEC.md > "Exit codes" mirrors it.

5 is documented-but-dead and stays that way. The SSH surface never observes ErrNotOwner: service.requireOwner collapses non-owner reads to ErrNotFound so existence cannot leak across identities.

Variables

This section is empty.

Functions

func MultiVersionNote added in v0.80.0

func MultiVersionNote(items []listItemView) bool

MultiVersionNote reports whether any row is charged for more versions than it serves, so the caller can explain a size that exceeds the served version.

Types

type CommandRecorder added in v1.1.0

type CommandRecorder interface {
	RecordCommand(verb, outcome string, d time.Duration)
}

CommandRecorder is the port the SSH server uses to report command outcomes. A narrow interface rather than a concrete type keeps the metrics implementation out of this package and lets tests assert on recorded calls without a Prometheus registry.

type PasteReader added in v0.51.0

type PasteReader interface {
	Get(domain.Slug) (domain.Paste, error)
}

PasteReader is the by-slug read the SSH layer needs beyond the verb service, used to mark which version `versions` currently serves. Depending on this rather than the verb service's repo keeps the SSH layer decoupled from how Manage is composed, in particular from the cache-invalidating decorator.

type Server

type Server struct {
	Addr        string
	HostKeyPath string
	ApexDomain  string // used in user-visible messages (help text, error hints).
	Upload      *service.Upload
	Deploy      *service.DeploySite // optional; nil disables static-site archive uploads
	Manage      service.PasteManager
	Pastes      PasteReader      // by-slug read for the `versions` current-marker
	Sites       SiteReader       // optional; by-slug site read for `url`/`qr` (nil = paste-only)
	KeyGate     *service.KeyGate // optional; nil disables the Sybil rate limit
	Now         func() time.Time // clock; defaults to time.Now when nil
	BuildURL    URLBuilder
	Logger      *log.Logger
	// Metrics is optional; nil records nothing. Kept as a port so this package
	// carries no Prometheus dependency and tests can assert on calls.
	Metrics CommandRecorder
}

Server is the SSH listener.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe blocks, returning whatever the listener returns (nil after a clean shutdown or net.ErrClosed).

HOSTTHIS_SSH_PROXY_PROTOCOL=true wraps the listener so PROXY protocol v1/v2 headers from a TCP-level forwarder (traefik, haproxy, nginx stream) are parsed and RemoteAddr() carries the real client IP. Required whenever SSH sits behind a TCP router: without it every session appears to originate from the forwarder and the Sybil per-subnet limit collapses to a global cap. With the flag set the header is mandatory: a headerless connection is refused rather than served with the forwarder's own address.

type SiteReader added in v0.56.0

type SiteReader interface {
	Get(domain.Slug) (domain.Site, error)
}

SiteReader resolves a deployed static-site slug to its URL for `url` / `qr`. Optional: nil means those verbs resolve paste slugs only. Like PasteReader the lookup is not owner-scoped - the URL is a public capability, so resolving a live slug leaks nothing the URL doesn't.

type URLBuilder

type URLBuilder func(domain.Slug) string

URLBuilder renders a slug as its public URL.

Jump to

Keyboard shortcuts

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