Run the control role on a laptop
This guide runs hopboxd with the control role on a Mac, without root. It reads the install info over the API. Then it sets the domain of the install and rotates the key-encryption key through the admin socket, and finds both actions in the audit log. It also makes an admin API key, opens the console on the laptop, and signs the CLI in without a browser. On a server, the same steps run as root with the default paths.
The release files of hopbox are not public yet. The hopbox team gives them on request. They hold no hopboxd for macOS, so this guide builds hopboxd from a checkout of the source of hopbox. The source is not public yet either, so this guide is for the people who work on hopbox. To run an install on a server, use Install hopbox on a Debian 13 server by hand or Install hopbox on your servers with Terraform.
What hopboxd run does
Section titled “What hopboxd run does”hopboxd run reads one small file, the bootstrap config. The file lists the roles of the server and a few paths (the bootstrap config of hopboxd). Everything else about the install lives in the control store and changes through the admin API.
The control role is a chain of units. Each unit needs the units before it, so hopboxd starts them in this order and stops them in the reverse order:
postgres: the bundled Postgres.store: the connection pool and the schema migrations.leader election: one control process becomes the leader and runs the leader jobs.api: the API listener, for every client.internal listener: the cluster API over TLS, for the servers of the install (the internal listener).admin socket: the admin API for root on this server.
Every call on every listener passes one request gate, which names the caller. Then one policy check in the service layer decides what that caller can do (the API server). On the admin socket, the kernel proves the user of the caller. On a laptop, hopboxd runs as you, so the socket accepts you without sudo.
What you need
Section titled “What you need”- A checkout of the source of hopbox, built with
make build. - The bundled Postgres:
make pgbuilds it on the first run and prints its dir. - curl 7.47 or later, for
--http2-prior-knowledge.
Write the bootstrap config
Section titled “Write the bootstrap config”A unix socket path has at most 103 bytes on macOS, so put the sockets in a short dir under /tmp. Group and others must not be able to write in the dir.
mkdir -p /tmp/hb && chmod 700 /tmp/hbcat > /tmp/hb/hopboxd.toml <<EOFroles = ["control"]data_dir = "$HOME/hopbox-dev"run_dir = "/tmp/hb"
[postgres]install = "$(make pg)"EOFThe API listener keeps its default address, 127.0.0.1:7080, and the internal listener keeps 127.0.0.1:7443.
Start hopboxd
Section titled “Start hopboxd”./bin/darwin_arm64/hopboxd run --config /tmp/hb/hopboxd.tomlThe first start creates the Postgres cluster in ~/hopbox-dev/pg, which takes a few seconds. hopboxd writes one JSON log record per line. The record hopboxd is ready means that every unit runs. Leave it running, and use a second terminal for the next steps.
The install has no key-encryption key yet, so it has no CA, and the internal listener has no certificate. hopboxd logs the internal listener has no certificate yet at level warn. The rotation in Act through the admin socket makes the first key. The next TLS handshake of the internal listener then makes the CA.
Read the install info
Section titled “Read the install info”GetInstallInfo needs no credential:
curl -s --http2-prior-knowledge \ 'http://127.0.0.1:7080/hopbox.v1.InstallService/GetInstallInfo?encoding=json&message=%7B%7D'{"version":"v0.0.0-20261016030431-02092f6e6161"}The domain is empty, so the JSON leaves it out. Your version names your commit.
An admin call on the API listener needs an admin API key, and this install has none yet. So the gate leaves the call anonymous, and the policy refuses it:
curl -s -X POST -H 'Content-Type: application/json' -d '{}' \ http://127.0.0.1:7080/hopbox.admin.v1.InstallConfigService/GetInstallConfig{"code":"unauthenticated","message":"this call needs a credential"}Make an admin API key makes one, so that the same call works.
Act through the admin socket
Section titled “Act through the admin socket”Set the domain of the install, then rotate the key-encryption key:
./bin/darwin_arm64/hopboxd admin --config /tmp/hb/hopboxd.toml config set --domain example.com./bin/darwin_arm64/hopboxd admin --config /tmp/hb/hopboxd.toml kek rotatedomain example.compublic_addresses -acme_directory_url https://acme-v02.api.letsencrypt.org/directoryacme_email -acme_terms_agreed falsemail_transport smtpversion 2update_time 2026-10-16T09:00:00Zfile:1admin finds the socket in the run_dir of the config, here /tmp/hb/admin.sock. The rotation wrote the key file ~/hopbox-dev/kek/1.key. Read the install info again, and it now has the domain:
curl -s --http2-prior-knowledge \ 'http://127.0.0.1:7080/hopbox.v1.InstallService/GetInstallInfo?encoding=json&message=%7B%7D'{"domain":"example.com","version":"v0.0.0-20261016030431-02092f6e6161"}Find the actions in the audit log
Section titled “Find the actions in the audit log”Every admin call writes an audit entry. Read the entries with the psql of the bundled Postgres, over its socket:
"$(make pg)/bin/psql" -h /tmp/hb/pg -U hopbox hopbox \ -c "SELECT actor_kind, action, target_id, details FROM audit_log ORDER BY id" actor_kind | action | target_id | details------------+-----------------------+-----------+------------------------------------------------------------------------ local_root | install_config.update | | {"domain": "example.com", "peer_pid": "49450", "peer_uid": "501", "old_domain": "", ...} local_root | keyring.rotate.start | file:1 | {"peer_pid": "49449", "peer_uid": "501", "idempotency": "5046b3c8...2fccc2d"} local_root | keyring.rotate | file:1 | {"peer_pid": "49449", "peer_uid": "501", "idempotency": "5046b3c8...2fccc2d"}(3 rows)The output here is cut short. The entry install_config.update holds each setting before and after the change, such as old_domain and domain. A rotation writes two entries: keyring.rotate.start before it writes the key file, and keyring.rotate after it (the admin API). idempotency is the SHA-256 of the idempotency key of the call. peer_uid and peer_pid name the user and the process that called through the socket.
Read the metrics
Section titled “Read the metrics”hopboxd counts every API call in its Prometheus metrics on 127.0.0.1:9464 (Metrics):
curl -s http://127.0.0.1:9464/metrics | grep '^hopbox_api_calls_total'hopbox_api_calls_total{code="ok",listener="admin_socket",procedure="/hopbox.admin.v1.InstallConfigService/UpdateInstallConfig"} 1hopbox_api_calls_total{code="ok",listener="admin_socket",procedure="/hopbox.admin.v1.KeyringService/RotateKEK"} 1hopbox_api_calls_total{code="ok",listener="api",procedure="/hopbox.v1.InstallService/GetInstallInfo"} 2hopbox_api_calls_total{code="unauthenticated",listener="api",procedure="/hopbox.admin.v1.InstallConfigService/GetInstallConfig"} 1Make an admin API key
Section titled “Make an admin API key”The admin API on the API listener takes an admin API key (CLI tokens, API keys, admin API keys, and SSH keys). Only root on a control server makes one, through the admin socket. On the laptop, that is you:
admin() { ./bin/darwin_arm64/hopboxd admin --config /tmp/hb/hopboxd.toml "$@"; }ADMIN_KEY="$(admin admin-key create --name terraform)"curl -s -X POST -H 'Content-Type: application/json' -H "Authorization: Bearer $ADMIN_KEY" -d '{}' \ http://127.0.0.1:7080/hopbox.admin.v1.InstallConfigService/GetInstallConfigThe admin key 01a145b6-3fc1-7ba1-a54d-d1dceac38930 (terraform) works until 2027-01-14T17:15:34Z. This is its only copy.{"config":{"domain":"example.com","version":"2","updateTime":"2026-10-16T17:14:47.254670Z"}}The key operates the install, but the keyring stays with root on the server:
curl -s -X POST -H 'Content-Type: application/json' -H "Authorization: Bearer $ADMIN_KEY" -d '{}' \ http://127.0.0.1:7080/hopbox.admin.v1.KeyringService/ListKEKs{"code":"permission_denied","message":"permission denied: a caller of kind admin_key may not do keyring.list"}The hopbox Terraform provider never sends its key to the server. It makes the key itself, and the server registers only its SHA-256. Do the same by hand:
KEY="hbxadm_$(head -c 32 /dev/urandom | base64 | tr '+/' '-_' | tr -d '=')"admin admin-key register --name bootstrap --sha256 "$(printf '%s' "$KEY" | shasum -a 256 | cut -d' ' -f1)"admin admin-key list01a145b6-400d-7c41-979e-14666fc2fe21 bootstrap 2027-01-14T17:15:34Z never01a145b6-3fc1-7ba1-a54d-d1dceac38930 terraform 2027-01-14T17:15:34Z 2026-10-16T17:15:34Z01a145b6-400d-7c41-979e-14666fc2fe21 bootstrap 2027-01-14T17:15:34Z neverThe first line is the output of register, and the next two are the list. $KEY now calls the admin API. Run register again with the same hash, and it prints the same key: a repeated install makes no second key. Delete a key with admin admin-key revoke --id <id>. The audit log has admin_key.create, admin_key.register, and admin_key.list with the actor local_root.
Open the console on the laptop
Section titled “Open the console on the laptop”make build builds the console into hopboxd, after corepack pnpm install. The console needs HTTPS. Its session cookie has the Secure flag, and each call with the cookie must come from the origin https://<domain> (Sessions, cookies, and sign-in links). On an install, the edge ends TLS. On the laptop, Caddy 2.8 or later does that job.
With hopboxd running, ask the API listener for a page of the console:
curl -sI http://127.0.0.1:7080/orgs | grep -i -e '^HTTP' -e '^content-security-policy'HTTP/1.1 200 OKContent-Security-Policy: default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self'; manifest-src 'self'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'If you get 404 and the text This hopboxd has no console, the binary came from go build. Run make build again.
A browser treats each name under localhost as the laptop itself. So hop.localhost works as the domain of the install without a DNS record:
admin config set --domain hop.localhostdomain hop.localhostpublic_addresses -...Save this file as /tmp/hb/Caddyfile:
hop.localhost { tls internal reverse_proxy 127.0.0.1:7080}tls internal makes Caddy sign a certificate for hop.localhost with its own local CA. Make the browser trust that CA once, then start Caddy in a third terminal:
caddy trustcaddy run --config /tmp/hb/Caddyfilecaddy trust asks for your password, because it adds the CA to the trust store of macOS. Caddy listens on port 443 and sends each request on to the API listener. It keeps the Host and Origin headers, so the checks of the session cookie pass.
Open https://hop.localhost/ in the browser. The console sends you to /signin. The install has no SMTP server and no OAuth app yet, so the page shows the command for a login link. Make the link, and open it in the browser:
admin login-link --email root@example.orghttps://hop.localhost/auth/login-link#token=tOzJ8YQyibHutrU34tIWLHnGd5XlzYs4WoIBXgSDh5IThe link signs in root@example.org once, until 2026-10-21T14:57:56Z.The page reads the token after #token=, removes it from the address bar, and signs you in. Then the steps of Use the console work, but a machine needs a node. The laptop runs only the control role, so a create fails with an error about capacity. Enroll a node first (Enroll the node role on one server). The CLI signs in to the same console with ./bin/darwin_arm64/hopbox login --url https://hop.localhost.
Stop Caddy with Ctrl-C. To remove the CA of Caddy from the trust store, run caddy untrust. To go back to the domain of the other guides, run admin config set --domain example.com.
Sign in the CLI with curl
Section titled “Sign in the CLI with curl”A person approves a sign-in of the hopbox CLI on the console page /device (Install the hopbox CLI). To test the device flow without a browser, approve it with curl, as that page does. This section needs the domain example.com, a signed-in instance admin, and the shell function browser of First sign-in on a new install. CLI tokens, API keys, admin API keys, and SSH keys gives each step of the flow.
Build the CLI, and give it a short name. On Linux, use bin/linux_amd64 or bin/linux_arm64:
make buildhopbox() { ./bin/darwin_arm64/hopbox "$@"; }API=http://127.0.0.1:7080Start the sign-in in the background, so the same shell can approve it:
hopbox login --url $API > /tmp/hb/login.out 2> /tmp/hb/login.err &sleep 1; cat /tmp/hb/login.errTo sign in, open this page in a browser and approve the code KWJQ-LBZV:
https://example.com/device?code=KWJQ-LBZV
Waiting for the approval. Press Ctrl-C to stop.The URL uses plain http, which the CLI accepts only for a loopback address. Now be the person at the console. Look up the code, check that the client is your own CLI, and approve it with the start time that the lookup showed:
CODE=$(sed -n 's/.*approve the code \([A-Z-]*\):/\1/p' /tmp/hb/login.err)browser -d "{\"userCode\":\"$CODE\"}" $API/hopbox.v1.AuthService/GetDeviceAuthorization | tee /tmp/hb/shown.jsonCREATED=$(python3 -c 'import json; print(json.load(open("/tmp/hb/shown.json"))["createTime"])')browser -d "{\"userCode\":\"$CODE\",\"createTime\":\"$CREATED\"}" $API/hopbox.v1.AuthService/ApproveDevice{"clientName":"hopbox CLI on user1-laptop", "clientIp":"127.0.0.1", "createTime":"2026-10-17T15:30:36.792730Z", "expireTime":"2026-10-17T15:40:36.792730Z"}{"clientName":"hopbox CLI on user1-laptop", "clientIp":"127.0.0.1", "createTime":"2026-10-17T15:30:36.792730Z"}The approval needs a sign-in within the last 10 minutes (Sessions, cookies, and sign-in links). If your sign-in is older, the call fails with permission_denied:
{"code":"permission_denied","message":"permission denied: this action needs a sign-in within the last 10 minutes. Sign in again, then retry","details":[{"type":"hopbox.v1.RecentSignInRequired","value":"CgMI2AQ","debug":{"maxAge":"600s"}}]}The code keeps waiting. Print a new login link, and put the part of the link after #token= in TOKEN. Then sign in with your old cookie, as a browser does. The new sign-in ends the old session and starts a new one. Take the new cookie, and approve again:
admin login-link --email root@example.orgTOKEN='<the part of the link after #token=>'curl -s -D /tmp/hb/headers -X POST -H 'Content-Type: application/json' \ -H 'Connect-Protocol-Version: 1' -H 'Origin: https://example.com' -H "Cookie: $COOKIE" \ -d "{\"token\":\"$TOKEN\"}" $API/hopbox.v1.AuthService/VerifyLoginLinkCOOKIE=$(sed -n 's/^Set-Cookie: \(__Host-hopbox_session=[^;]*\).*/\1/p' /tmp/hb/headers)browser -d "{\"userCode\":\"$CODE\",\"createTime\":\"$CREATED\"}" $API/hopbox.v1.AuthService/ApproveDeviceThe CLI polls every 5 seconds, so it sees the approval within a few seconds:
wait; cat /tmp/hb/login.outSigned in to http://127.0.0.1:7080 as root@example.org (unverified). The profile default is active.Added the SSH key ~/.ssh/hopbox_ed25519 (SHA256:rkEGrocWsFODhePtstCZFcyj1D0BUmGYu1rexwam/mo) to your account.To see a refresh of the CLI tokens at once, mark the access token as ended in the file. On Linux, use sed -i without '':
sed -i '' 's/^\( access_token_expire_time = \).*/\12026-01-01T00:00:00Z/' ~/.config/hopbox/credentials.tomlhopbox --debug whoami 2>&1 | head -1time=2026-10-17T17:31:00.445+02:00 level=DEBUG msg="refreshed the CLI tokens" cli_sign_in=01a14a7c-abae-7e4d-bde7-34c1e1d6870dCall the access calls on the laptop
Section titled “Call the access calls on the laptop”The API listener of the laptop listens on 127.0.0.1:7080 without TLS. So the grpcurl calls of Run commands and copy files in a machine need -plaintext there, and an API key of your org in KEY:
API=127.0.0.1:7080hb() { grpcurl -plaintext -H "Authorization: Bearer $KEY" "$@"; }Each access call but the log needs a running machine, so the laptop also needs a node (Enroll the node role on one server). Without one, a new machine stays pending, and the calls answer failed_precondition.
Add a second control server
Section titled “Add a second control server”Two control servers share one control store (Run the control store on an external Postgres), and they need the same key-encryption keys. Copy the key dir of the first server to the second one before the second one starts for the first time. Do not run hopboxd install on it first with the control role and no keys, because that makes a first key that the other server does not have. The start of the control role checks that its key files open the install CA, and fails when they do not.
On the first server, cp1, copy the dir as root. The dir has the mode 0700, and each key file has the mode 0400 and belongs to root:
sudo rsync -a /var/lib/hopbox/kek/ root@cp2:/var/lib/hopbox/kek/ssh root@cp2 ls -l /var/lib/hopbox/kektotal 4-r-------- 1 root root 32 Oct 16 09:00 1.keyStart hopboxd on cp2. If the keys are wrong, it stops with control: the key files in /var/lib/hopbox/kek do not open the install CA of the control store: ... Copy the key files of a running control server there.
Later, add a key to both servers with a stage and a promote. A plain kek rotate fails while the other server is live:
sudo hopboxd admin kek stagesudo scp -p /var/lib/hopbox/kek/2.staged root@cp2:/var/lib/hopbox/kek/2.stagedsudo hopboxd admin kek promote file:2sudo hopboxd admin kek rewrapfile:2 /var/lib/hopbox/kek/2.stagedfile:2rewrapped 3 to file:2file:1 0file:2 3 currentSealing gives the steps and the errors. The hopbox Terraform provider copies the key files to a new control server that it sets up (hopbox Terraform provider). You copy a staged key yourself, over SSH.
Stop hopboxd
Section titled “Stop hopboxd”Press Ctrl-C in the first terminal. hopboxd stops the units in the reverse order: the admin socket, the internal listener, the API, the leader election, the store, Postgres, and the metrics listener last. It removes /tmp/hb/admin.sock and exits with status 0. The next start keeps the cluster, the domain, and the key.
To start again from nothing, stop hopboxd, then remove the dirs ~/hopbox-dev and /tmp/hb.
The node role runs machines, so it needs Linux with KVM, and its enrollment fails on a Mac. Enroll the node role on one server enrolls the node role of a Linux server with the control role of the same server. Serve the domain of an install with the DNS role runs the DNS role.