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 ¶
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 ¶
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 Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service runs install jobs over SSH.
func New ¶
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.