Machines overview
A machine is one Ubuntu server that sg has turned into a hardened LXD host. You describe it in a machine.yaml, and sg machine create gets it there one verified change at a time.
What happens to the server
sg machine create applies up to eight changes, always in this order. Each one is checked after it runs; the run stops and records the failure if a check doesn't pass.
| # | Change | What it does | Risk |
|---|---|---|---|
| 1 | install.packages | Installs fail2ban and unattended-upgrades (or your list). | low |
| 2 | harden.ssh | Turns off password logins and root password login, and checks the effective sshd policy. | medium |
| 3 | create.deploy-user | Creates the deploy user with your public key and non-interactive sudo. | medium |
| 4 | install.tailscale | Installs Tailscale and joins your tailnet with the auth key from your environment. | medium |
| 5 | firewall.guard | Loads an nftables guard (sg_guard) so the LXD API is reachable only on the tailnet. | high |
| 6 | storage.zfs | Writes /etc/modprobe.d/sg-zfs.conf to cap the ZFS ARC, so storage can't starve the host. | low |
| 7 | install.lxd | Installs the LXD snap (held on 5.21/stable), creates the file-backed storage pool, bridge and profiles, and binds the API to tailnet:8444. | high |
| 8 | verify.isolation | Boots a throwaway VM (sg-isolation-<run>), checks what it can and can't reach, then deletes it. Leaves nothing behind. | none |
A change that is already in the right state is skipped. Run create on a converged machine and it tells you there's nothing to do.
The verbs
| Command | Effect |
|---|---|
sg machine init | Local only. Writes a machine.yaml by asking questions, or registers one you wrote with --config. |
sg machine plan | Read-only. Connects over SSH and prints the ordered changes. |
sg machine create | Changes the host. Applies the plan after you confirm. |
sg machine status | Read-only. Reports recorded state, drift and last-applied times. Never repairs. |
sg machine rollback | Changes the host. Undoes the last run's reversible changes. |
sg machine destroy | Changes the host. Removes everything sg recorded, in reverse order. |
What it needs
- Ubuntu
22.04or24.04LTS, reachable over SSH as root with your key. - The host key in your
~/.ssh/known_hosts.sgnever edits that file. - A Tailscale auth key in an environment variable (
TS_AUTHKEYby default).
What it never does
- Reboot the host. If a reboot is pending, it says so and leaves it to you.
- Bind the LXD API to port
8443, a wildcard or loopback. - Delete the ZFS pool or LXD on a rollback. Those hold data; only
destroyremoves them.
Where to next
- Launch your first machine: the full walkthrough.
- Machine examples: specs for common setups.
- Status, rollback and destroy: living with a machine.
- Form a cluster: once you have three.