[{"data":1,"prerenderedAt":464},["ShallowReactive",2],{"docs-\u002Fdocs\u002Fmachines":3},{"id":4,"title":5,"body":6,"description":456,"extension":457,"meta":458,"navigation":459,"path":460,"seo":461,"stem":462,"__hash__":463},"docs\u002Fdocs\u002Fmachines\u002Findex.md","Machines overview",{"type":7,"value":8,"toc":447},"minimark",[9,13,30,35,40,238,245,259,263,353,357,389,393,412,416],[10,11,5],"h1",{"id":12},"machines-overview",[14,15,16,17,21,22,25,26,29],"p",{},"A machine is one Ubuntu server that ",[18,19,20],"code",{},"sg"," has turned into a hardened LXD host. You describe it in a ",[18,23,24],{},"machine.yaml",", and ",[18,27,28],{},"sg machine create"," gets it there one verified change at a time.",[31,32,34],"h2",{"id":33},"what-happens-to-the-server","What happens to the server",[14,36,37,39],{},[18,38,28],{}," 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.",[41,42,43,62],"table",{},[44,45,46],"thead",{},[47,48,49,53,56,59],"tr",{},[50,51,52],"th",{},"#",[50,54,55],{},"Change",[50,57,58],{},"What it does",[50,60,61],{},"Risk",[63,64,65,92,110,131,148,170,191,216],"tbody",{},[47,66,67,71,76,87],{},[68,69,70],"td",{},"1",[68,72,73],{},[18,74,75],{},"install.packages",[68,77,78,79,82,83,86],{},"Installs ",[18,80,81],{},"fail2ban"," and ",[18,84,85],{},"unattended-upgrades"," (or your list).",[68,88,89],{},[18,90,91],{},"low",[47,93,94,97,102,105],{},[68,95,96],{},"2",[68,98,99],{},[18,100,101],{},"harden.ssh",[68,103,104],{},"Turns off password logins and root password login, and checks the effective sshd policy.",[68,106,107],{},[18,108,109],{},"medium",[47,111,112,115,120,127],{},[68,113,114],{},"3",[68,116,117],{},[18,118,119],{},"create.deploy-user",[68,121,122,123,126],{},"Creates the ",[18,124,125],{},"deploy"," user with your public key and non-interactive sudo.",[68,128,129],{},[18,130,109],{},[47,132,133,136,141,144],{},[68,134,135],{},"4",[68,137,138],{},[18,139,140],{},"install.tailscale",[68,142,143],{},"Installs Tailscale and joins your tailnet with the auth key from your environment.",[68,145,146],{},[18,147,109],{},[47,149,150,153,158,165],{},[68,151,152],{},"5",[68,154,155],{},[18,156,157],{},"firewall.guard",[68,159,160,161,164],{},"Loads an nftables guard (",[18,162,163],{},"sg_guard",") so the LXD API is reachable only on the tailnet.",[68,166,167],{},[18,168,169],{},"high",[47,171,172,175,180,187],{},[68,173,174],{},"6",[68,176,177],{},[18,178,179],{},"storage.zfs",[68,181,182,183,186],{},"Writes ",[18,184,185],{},"\u002Fetc\u002Fmodprobe.d\u002Fsg-zfs.conf"," to cap the ZFS ARC, so storage can't starve the host.",[68,188,189],{},[18,190,91],{},[47,192,193,196,201,212],{},[68,194,195],{},"7",[68,197,198],{},[18,199,200],{},"install.lxd",[68,202,203,204,207,208,211],{},"Installs the LXD snap (held on ",[18,205,206],{},"5.21\u002Fstable","), creates the file-backed storage pool, bridge and profiles, and binds the API to ",[18,209,210],{},"tailnet:8444",".",[68,213,214],{},[18,215,169],{},[47,217,218,221,226,233],{},[68,219,220],{},"8",[68,222,223],{},[18,224,225],{},"verify.isolation",[68,227,228,229,232],{},"Boots a throwaway VM (",[18,230,231],{},"sg-isolation-\u003Crun>","), checks what it can and can't reach, then deletes it. Leaves nothing behind.",[68,234,235],{},[18,236,237],{},"none",[14,239,240,241,244],{},"A change that is already in the right state is skipped. Run ",[18,242,243],{},"create"," on a converged machine and it tells you there's nothing to do.",[246,247,249],"note",{"kind":248},"warning",[14,250,251,252,255,256,258],{},"Starting LXD sets ",[18,253,254],{},"kernel.apparmor_restrict_unprivileged_userns=0"," on the host, and the snap repeats this every time the daemon starts. The plan says so on the ",[18,257,200],{}," row. VMs don't need this relaxation.",[31,260,262],{"id":261},"the-verbs","The verbs",[41,264,265,275],{},[44,266,267],{},[47,268,269,272],{},[50,270,271],{},"Command",[50,273,274],{},"Effect",[63,276,277,293,303,316,326,338],{},[47,278,279,284],{},[68,280,281],{},[18,282,283],{},"sg machine init",[68,285,286,287,289,290,211],{},"Local only. Writes a ",[18,288,24],{}," by asking questions, or registers one you wrote with ",[18,291,292],{},"--config",[47,294,295,300],{},[68,296,297],{},[18,298,299],{},"sg machine plan",[68,301,302],{},"Read-only. Connects over SSH and prints the ordered changes.",[47,304,305,309],{},[68,306,307],{},[18,308,28],{},[68,310,311,315],{},[312,313,314],"strong",{},"Changes the host."," Applies the plan after you confirm.",[47,317,318,323],{},[68,319,320],{},[18,321,322],{},"sg machine status",[68,324,325],{},"Read-only. Reports recorded state, drift and last-applied times. Never repairs.",[47,327,328,333],{},[68,329,330],{},[18,331,332],{},"sg machine rollback",[68,334,335,337],{},[312,336,314],{}," Undoes the last run's reversible changes.",[47,339,340,345],{},[68,341,342],{},[18,343,344],{},"sg machine destroy",[68,346,347,349,350,352],{},[312,348,314],{}," Removes everything ",[18,351,20],{}," recorded, in reverse order.",[31,354,356],{"id":355},"what-it-needs","What it needs",[358,359,360,372,382],"ul",{},[361,362,363,364,367,368,371],"li",{},"Ubuntu ",[18,365,366],{},"22.04"," or ",[18,369,370],{},"24.04"," LTS, reachable over SSH as root with your key.",[361,373,374,375,378,379,381],{},"The host key in your ",[18,376,377],{},"~\u002F.ssh\u002Fknown_hosts",". ",[18,380,20],{}," never edits that file.",[361,383,384,385,388],{},"A Tailscale auth key in an environment variable (",[18,386,387],{},"TS_AUTHKEY"," by default).",[31,390,392],{"id":391},"what-it-never-does","What it never does",[358,394,395,398,405],{},[361,396,397],{},"Reboot the host. If a reboot is pending, it says so and leaves it to you.",[361,399,400,401,404],{},"Bind the LXD API to port ",[18,402,403],{},"8443",", a wildcard or loopback.",[361,406,407,408,411],{},"Delete the ZFS pool or LXD on a rollback. Those hold data; only ",[18,409,410],{},"destroy"," removes them.",[31,413,415],{"id":414},"where-to-next","Where to next",[358,417,418,426,433,440],{},[361,419,420,425],{},[421,422,424],"a",{"href":423},"\u002Fdocs\u002Fmachines\u002Ffirst-machine","Launch your first machine",": the full walkthrough.",[361,427,428,432],{},[421,429,431],{"href":430},"\u002Fdocs\u002Fmachines\u002Fexamples","Machine examples",": specs for common setups.",[361,434,435,439],{},[421,436,438],{"href":437},"\u002Fdocs\u002Fmachines\u002Flifecycle","Status, rollback and destroy",": living with a machine.",[361,441,442,446],{},[421,443,445],{"href":444},"\u002Fdocs\u002Fmachines\u002Fclusters","Form a cluster",": once you have three.",{"title":448,"searchDepth":449,"depth":449,"links":450},"",2,[451,452,453,454,455],{"id":33,"depth":449,"text":34},{"id":261,"depth":449,"text":262},{"id":355,"depth":449,"text":356},{"id":391,"depth":449,"text":392},{"id":414,"depth":449,"text":415},"What sg machine does to a server, the eight changes it applies, and the six verbs you use to manage one.","md",{},true,"\u002Fdocs\u002Fmachines",{"title":5,"description":456},"docs\u002Fmachines\u002Findex","K0Cj0TzmD4xwEvsLe7rp0eGo1unrncWVIM1wMMEfTKA",1796464240882]