provision

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: AGPL-3.0 Imports: 31 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 provision contains the panel's SSH provisioning primitives.

Index

Constants

View Source
const AdminPagePath = "/nodes/install"

AdminPagePath is the exact path used by the authenticated panel wizard. The HTTP server also serves its slash-suffixed form without redirecting.

View Source
const DefaultSSHPort = 22

DefaultSSHPort is used when the owner leaves the SSH port blank.

Variables

View Source
var (
	// ErrUnsafeTarget covers malformed hosts and any address that is not public unicast.
	ErrUnsafeTarget = errors.New("provision: SSH target must resolve only to public unicast addresses")
	// ErrNoAddress means DNS returned no addresses for the target.
	ErrNoAddress = errors.New("provision: SSH target has no usable address")
)
View Source
var (

	// ErrHostKey reports that the server key changed after the owner confirmed it.
	ErrHostKey = errors.New("provision: SSH host key does not match the confirmed fingerprint")
)

Functions

This section is empty.

Types

type BinarySource

type BinarySource interface {
	OpenNodeBinary(goos, goarch string) (*os.File, int64, string, error)
}

BinarySource returns a file from the currently trusted release bundle and the digest in its signed manifest.

type Client

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

Client performs password-free host-key discovery and pinned SSH connections. The production constructor uses the system resolver and a standard TCP dialer.

func NewClient

func NewClient() *Client

NewClient builds a production SSH client with bounded timeouts.

func (*Client) Dial

func (c *Client) Dial(ctx context.Context, target Target, password, confirmedFingerprint string) (*Connection, error)

Dial authenticates as root only after the host presents the fingerprint the owner confirmed in the UI. A changed or unexpected key never receives the password.

func (*Client) DialAs

func (c *Client) DialAs(ctx context.Context, target Target, username, password, confirmedFingerprint string) (*Connection, error)

DialAs authenticates with the supplied account after the server presents the confirmed host key. Non-root accounts are accepted only when the remote preflight proves passwordless sudo works.

func (*Client) Fingerprint

func (c *Client) Fingerprint(ctx context.Context, target Target) (string, error)

Fingerprint reads one reachable server key without authenticating. The SSH handshake is stopped as soon as the key is received, before an auth request.

type Config

type Config struct {
	StepUp     func(context.Context) error
	Nodes      NodeManager
	Binaries   BinarySource
	PanelAddr  string
	AgentSNI   string
	Log        *slog.Logger
	Now        func() time.Time
	SSH        *Client
	WaitOnline time.Duration
	RetryDelay time.Duration
}

Config contains the services needed for durable SSH provisioning.

type Connection

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

Connection is an authenticated SSH client whose lifetime follows the context passed to Dial. Close it when the provisioning phase ends.

func (*Connection) Close

func (c *Connection) Close() error

Close ends the SSH connection and stops its cancellation hook.

func (*Connection) NewSession

func (c *Connection) NewSession() (*ssh.Session, error)

NewSession opens one SSH session on the verified connection.

func (*Connection) PrivilegedCommand

func (c *Connection) PrivilegedCommand(command string) string

PrivilegedCommand runs a command with root privileges without prompting for a second password.

type NodeManager

type NodeManager interface {
	CreateProvisionEnrollment(context.Context, NodeSpec, string, time.Time, time.Time) (token, caFingerprint string, err error)
	ProvisionNodeState(context.Context, string) (string, error)
	ProvisionNodeConnected(string) bool
}

NodeManager joins a durable installation job to the fleet CA and agent stream.

type NodeSpec

type NodeSpec struct {
	ID, Name, Address, CountryCode, Location, Provider string
}

NodeSpec is the node metadata reserved by one provisioning job.

type Service

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

Service exposes the owner-only provisioning API and runs durable jobs.

func NewService

func NewService(st *store.Store, vlt *vault.Vault, cfg Config) (*Service, error)

NewService builds the provisioning API and its background worker.

func (*Service) CancelNodeProvision

func (s *Service) CancelNodeProvision(ctx context.Context, jobID string) (string, error)

CancelNodeProvision stops a queued install immediately or asks the active SSH worker to stop. An active cancellation is reported as uncertain because remote commands may already have changed the host.

func (*Service) CheckSSH

CheckSSH authenticates only after the submitted fingerprint exactly matches the host key.

func (*Service) GetNodeProvision

GetNodeProvision returns public job status; its encrypted secret is omitted.

func (*Service) GetSSHFingerprint

GetSSHFingerprint reads the remote SSH host key without sending authentication.

func (*Service) Handler

func (s *Service) Handler(opts ...connect.HandlerOption) (string, http.Handler)

Handler mounts the owner-only ProvisioningService Connect handler.

func (*Service) ListNodeProvisionEvents

ListNodeProvisionEvents returns only stable event codes, never remote output.

func (*Service) ListNodeProvisions

ListNodeProvisions returns the most recently updated provisioning jobs.

func (*Service) ListNodeServerAccess

ListNodeServerAccess returns connection metadata only; encrypted credentials stay inside the panel.

func (*Service) PageHandler

func (s *Service) PageHandler() http.Handler

PageHandler serves the Go-rendered SSH installation wizard. The HTTP server wraps it in the same owner-only session and cross-origin protections as the admin API.

func (*Service) RetryNodeProvision

RetryNodeProvision requeues a failed job with freshly supplied SSH login credentials.

func (*Service) RevealNodeServerPassword added in v0.1.1

RevealNodeServerPassword is an owner-only, step-up protected panel operation. It is intentionally not registered as an MCP tool: the admin can retrieve the encrypted-at-rest credential in the panel, while an agent can only request a generated password rotation and receives its status.

func (*Service) RotateNodeServerPassword

RotateNodeServerPassword changes the OS login password over the pinned SSH connection and verifies it with a fresh authentication before the panel promotes the encrypted credential.

func (*Service) Run

func (s *Service) Run(ctx context.Context) error

Run recovers interrupted jobs and executes queued installations serially.

func (*Service) StartNodeProvision

StartNodeProvision stores the SSH credential sealed to this job and queues installation.

type Target

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

Target is a normalized SSH host and port. Construct it with NewTarget so DNS search suffixes, zones and malformed host names cannot alter where we dial.

func NewTarget

func NewTarget(host string, port uint32) (Target, error)

NewTarget validates and normalizes an SSH hostname or IP address and port.

func (Target) Address

func (t Target) Address() string

Address returns the target in host:port form, with IPv6 brackets when needed.

func (Target) Host

func (t Target) Host() string

Host returns the normalized SSH hostname or IP address.

func (Target) Port

func (t Target) Port() uint16

Port returns the normalized SSH port.

Jump to

Keyboard shortcuts

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