sshinstall

package
v0.16.521 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 37 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 sshinstall is the hub's «Свой сервер по SSH» way of connecting a machine. The owner adds the public key of their space to the server's authorized_keys and gives the hub an address; the hub connects once, looks at the server, runs the same install command a person would paste, waits for the machine to come online, and forgets the session (docs/hub/architecture.md, "Ways to connect").

Every space has an SSH key pair of its own, made on first use: the owners of that space are the only people who are shown the public half, and the private half (encrypted in the database, with a key the hub keeps outside it) signs in only for an install an owner of that space starts. A key shared by all the spaces would let the owner of one install on the servers of another.

The hub has never seen the server, so its host key is the owner's to confirm: the first request (no hostKeyFingerprint) goes as far as the handshake, shows the fingerprint and stops before any key is offered; the same request again with that fingerprint carries on, and a server whose key is another one is refused.

The progress is a job of kind ssh-install on the space's event stream, for the owners: steps ssh, preflight, install, online.

Index

Constants

View Source
const SecretKeyFile = "secret_key"

SecretKeyFile is the file in the data folder the hub's encryption key is made in when HUB_SECRET_KEY is not set.

Variables

This section is empty.

Functions

func MasterKey added in v0.16.15

func MasterKey(dataDir, configured string) ([]byte, error)

MasterKey is the key the hub derives its other secrets from (the sites' cookie key); see masterKey.

Types

type Deps

type Deps struct {
	Config   *config.Config
	DB       *store.DB
	Auth     *auth.Service
	Spaces   *spaces.Service
	Machines *machines.Service
	Reg      *link.Registry
	Events   *events.Broker
	Limiter  *ratelimit.Limiter
	Log      *slog.Logger
	// Now is the clock; nil means time.Now.
	Now func() time.Time
	// Dial opens connections; nil uses the network, which refuses addresses that are not on the public internet
	// (HUB_SSH_ALLOW_PRIVATE allows them, outside the cloud edition).
	Dial Dialer
	// OnlineWait is how long the last step waits for the machine; zero means 90 seconds. Tests shorten it.
	OnlineWait time.Duration
}

Deps are what the service is built from.

type Dialer

type Dialer func(ctx context.Context, network, addr string) (net.Conn, error)

Dialer opens the network connection to a server. Tests replace it.

type Service

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

Service runs install jobs over SSH.

func New

func New(d Deps) (*Service, error)

New makes the service and loads (or makes) the key that encrypts the spaces' SSH keys. A key that cannot be had is an error: the caller leaves the way off.

func (*Service) Available

func (s *Service) Available() bool

Available says the way is on: it has a key and the setting allows it.

func (*Service) Close

func (s *Service) Close()

Close stops the jobs still running and waits for them.

func (*Service) Mount

func (s *Service) Mount(sub *http.ServeMux)

Mount registers the endpoints on the router of the paths under a space.

Jump to

Keyboard shortcuts

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