sshpool

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: GPL-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package sshpool dials an instance's SSH endpoint with its stored credentials and reports how the presented host key relates to the pinned one. Nothing here writes to the database: pinning is the caller's decision, taken on the report this package returns.

Index

Constants

This section is empty.

Variables

View Source
var ErrConnect = errors.New("could not connect to the SSH host")

ErrConnect marks a failure to reach the host or complete the handshake, as opposed to a fault in what qui stored: the caller answers the two differently, and only the first earns an unreadable pin its precedence.

Functions

This section is empty.

Types

type Capabilities

type Capabilities struct {
	SFTP        bool
	Statvfs     bool
	Hardlink    bool
	Limits      bool
	Exec        bool
	GNUUserland bool
}

Capabilities is what the server lets us do, probed read-only.

type Dialer

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

Dialer opens one-shot SSH connections. There is no pool yet: every call dials, does its work and closes.

func NewDialer

func NewDialer(creds credentialSource) *Dialer

func (*Dialer) Confirm

func (d *Dialer) Confirm(ctx context.Context, inst *models.Instance, hostKey []byte) error

Confirm dials the instance and succeeds only if the host presents hostKey, so the caller can pin the key the user was shown rather than whatever the host offers at pin time. hostKey is in SSH wire format, the form the pin column holds.

func (*Dialer) Test

func (d *Dialer) Test(ctx context.Context, inst *models.Instance) (*Report, error)

Test dials the instance and reports the host key, its relation to the pin, and — unless the key mismatched or the pin is unreadable — what the server can do.

type MismatchError

type MismatchError struct {
	Presented ssh.PublicKey
	Pinned    ssh.PublicKey
}

MismatchError reports that the host presented a key other than the expected one. Error prints fingerprints only, so the message is safe to log; the fields carry the keys for callers that need them.

func (*MismatchError) Error

func (e *MismatchError) Error() string

type Report

type Report struct {
	Status       Status
	HostKey      ssh.PublicKey
	PinnedKey    ssh.PublicKey // mismatch only
	Capabilities *Capabilities // nil on mismatch and pin_unreadable: no session is opened
}

Report is the outcome of Test. A mismatch is a result, not a failure: the user has to see both keys to decide whether the host was re-keyed or replaced.

type Status

type Status string

Status is how the host key the server presented relates to the stored pin.

const (
	StatusUnpinned Status = "unpinned"
	StatusPinned   Status = "pinned"
	StatusMismatch Status = "mismatch"
	// StatusPinUnreadable: the stored pin does not decrypt. The presented key
	// is reported so the user can replace the pin through the same heavy
	// confirmation a mismatch gets; nothing is trusted and nothing is probed.
	StatusPinUnreadable Status = "pin_unreadable"
)

Jump to

Keyboard shortcuts

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