Documentation
¶
Overview ¶
Package provision contains the panel's SSH provisioning primitives.
Index ¶
- Constants
- Variables
- type BinarySource
- type Client
- type Config
- type Connection
- type NodeManager
- type NodeSpec
- type Service
- func (s *Service) CancelNodeProvision(ctx context.Context, jobID string) (string, error)
- func (s *Service) CheckSSH(ctx context.Context, req *connect.Request[adminv1.CheckSSHRequest]) (*connect.Response[adminv1.CheckSSHResponse], error)
- func (s *Service) GetNodeProvision(ctx context.Context, req *connect.Request[adminv1.GetNodeProvisionRequest]) (*connect.Response[adminv1.GetNodeProvisionResponse], error)
- func (s *Service) GetSSHFingerprint(ctx context.Context, req *connect.Request[adminv1.GetSSHFingerprintRequest]) (*connect.Response[adminv1.GetSSHFingerprintResponse], error)
- func (s *Service) Handler(opts ...connect.HandlerOption) (string, http.Handler)
- func (s *Service) ListNodeProvisionEvents(ctx context.Context, ...) (*connect.Response[adminv1.ListNodeProvisionEventsResponse], error)
- func (s *Service) ListNodeProvisions(ctx context.Context, _ *connect.Request[adminv1.ListNodeProvisionsRequest]) (*connect.Response[adminv1.ListNodeProvisionsResponse], error)
- func (s *Service) ListNodeServerAccess(ctx context.Context, _ *connect.Request[adminv1.ListNodeServerAccessRequest]) (*connect.Response[adminv1.ListNodeServerAccessResponse], error)
- func (s *Service) PageHandler() http.Handler
- func (s *Service) RetryNodeProvision(ctx context.Context, req *connect.Request[adminv1.RetryNodeProvisionRequest]) (*connect.Response[adminv1.RetryNodeProvisionResponse], error)
- func (s *Service) RevealNodeServerPassword(ctx context.Context, ...) (*connect.Response[adminv1.RevealNodeServerPasswordResponse], error)
- func (s *Service) RotateNodeServerPassword(ctx context.Context, ...) (*connect.Response[adminv1.RotateNodeServerPasswordResponse], error)
- func (s *Service) Run(ctx context.Context) error
- func (s *Service) StartNodeProvision(ctx context.Context, req *connect.Request[adminv1.StartNodeProvisionRequest]) (*connect.Response[adminv1.StartNodeProvisionResponse], error)
- type Target
Constants ¶
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.
const DefaultSSHPort = 22
DefaultSSHPort is used when the owner leaves the SSH port blank.
Variables ¶
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") )
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.
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 ¶
NewService builds the provisioning API and its background worker.
func (*Service) CancelNodeProvision ¶
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 ¶
func (s *Service) CheckSSH(ctx context.Context, req *connect.Request[adminv1.CheckSSHRequest]) (*connect.Response[adminv1.CheckSSHResponse], error)
CheckSSH authenticates only after the submitted fingerprint exactly matches the host key.
func (*Service) GetNodeProvision ¶
func (s *Service) GetNodeProvision(ctx context.Context, req *connect.Request[adminv1.GetNodeProvisionRequest]) (*connect.Response[adminv1.GetNodeProvisionResponse], error)
GetNodeProvision returns public job status; its encrypted secret is omitted.
func (*Service) GetSSHFingerprint ¶
func (s *Service) GetSSHFingerprint(ctx context.Context, req *connect.Request[adminv1.GetSSHFingerprintRequest]) (*connect.Response[adminv1.GetSSHFingerprintResponse], error)
GetSSHFingerprint reads the remote SSH host key without sending authentication.
func (*Service) ListNodeProvisionEvents ¶
func (s *Service) ListNodeProvisionEvents(ctx context.Context, req *connect.Request[adminv1.ListNodeProvisionEventsRequest]) (*connect.Response[adminv1.ListNodeProvisionEventsResponse], error)
ListNodeProvisionEvents returns only stable event codes, never remote output.
func (*Service) ListNodeProvisions ¶
func (s *Service) ListNodeProvisions(ctx context.Context, _ *connect.Request[adminv1.ListNodeProvisionsRequest]) (*connect.Response[adminv1.ListNodeProvisionsResponse], error)
ListNodeProvisions returns the most recently updated provisioning jobs.
func (*Service) ListNodeServerAccess ¶
func (s *Service) ListNodeServerAccess(ctx context.Context, _ *connect.Request[adminv1.ListNodeServerAccessRequest]) (*connect.Response[adminv1.ListNodeServerAccessResponse], error)
ListNodeServerAccess returns connection metadata only; encrypted credentials stay inside the panel.
func (*Service) PageHandler ¶
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 ¶
func (s *Service) RetryNodeProvision(ctx context.Context, req *connect.Request[adminv1.RetryNodeProvisionRequest]) (*connect.Response[adminv1.RetryNodeProvisionResponse], error)
RetryNodeProvision requeues a failed job with freshly supplied SSH login credentials.
func (*Service) RevealNodeServerPassword ¶ added in v0.1.1
func (s *Service) RevealNodeServerPassword(ctx context.Context, req *connect.Request[adminv1.RevealNodeServerPasswordRequest]) (*connect.Response[adminv1.RevealNodeServerPasswordResponse], error)
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 ¶
func (s *Service) RotateNodeServerPassword(ctx context.Context, req *connect.Request[adminv1.RotateNodeServerPasswordRequest]) (*connect.Response[adminv1.RotateNodeServerPasswordResponse], error)
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) StartNodeProvision ¶
func (s *Service) StartNodeProvision(ctx context.Context, req *connect.Request[adminv1.StartNodeProvisionRequest]) (*connect.Response[adminv1.StartNodeProvisionResponse], error)
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 (Target) Address ¶
Address returns the target in host:port form, with IPv6 brackets when needed.