This repository is an allowlisted reconstruction recipe, not a copy of a home directory. Keeping the repository private does not make credentials safe to commit.
- SSH private keys, GitHub tokens, Tailscale node identity or auth keys.
- OMP, Claude, Codex, or other provider authentication stores.
- Browser profiles, cookies, password stores, desktop login sessions, or VNC passwords.
- Agent transcripts, fleet task history, private project working trees, database files, or Docker volumes.
.envfiles, Terraform state, runtime sockets, PID files, and caches.
A service unit can carry an inline API credential. Never copy such a unit verbatim. Recreated services must load credentials from a private runtime environment file, never from tracked unit contents.
Authenticate each CLI interactively under the account that will run it. Do not copy an old host's credential database to make a tool appear configured. GitHub repository access, model subscriptions, organization permissions, and tailnet membership are separate prerequisites; installing a binary does not grant them.
Two exceptions move state between the operator's own hosts:
- Shared fleet credentials in
super.env: a new host fetches them from Cloudflare Secrets Store withscripts/fetch-secrets.sh. See Shared credentials. - Each Firstmate home's
data/andconfig/: they move host to host over SSH (rsync -a, owner-only), never through Git, a registry, or an image, and only for the cutover and rollback syncs of Moving the agents to a new host.
Keep local credential files outside the checkout, in owner-only directories with mode 0700; files should have mode 0600.
Services should use EnvironmentFile= or Docker secrets, except for iMessage credential loading.
Do not put tokens into shell command arguments or public URLs.
The persistent desktop browser uses exactly one profile, ~/.vnc-chrome-profile. Never clone, trim, archive into Git, or replace it. Log in on the destination device. The browser pruner excludes persistent profiles, attached browsers, and headed browsers.
Keep application and desktop listeners on loopback unless a reviewed deployment explicitly needs another binding. The password gateway is opt-in and off until selected. When enabled, it provides password access through a Cloudflare Quick Tunnel to the loopback ports. The gateway opens no port on the host. SSH port forwarding and Tailscale are the other ways in. Do not publish a Docker socket or mount the host socket into an agent container; it grants host-level control.
Run npx crewship init or bunx crewship init on the laptop.
Run the installer and later setup commands on the target server.
The guide uses existing SSH keys from your SSH configuration or agent.
It does not create keys or collect, copy, or store SSH passwords or private keys.
It keeps host-key checks on and agent forwarding off.
Verify a new fingerprint against the provider console before accepting it.
Stop on a changed key; do not bypass the warning.
Approve the named server and install action before the guide connects.
If no usable key exists, use the manual server command from Install.
Type any sudo password directly in the native terminal; never pass it through an agent or a saved answer.
GitHub and model-provider sign-ins remain manual on the server.
Loopback is shared by local accounts. The optional desktop therefore requires an operator-created private VNC credential in addition to SSH transport. It never offers unauthenticated RFB access. Its service will not kill another desktop to claim an occupied display.
Tailscale is the private-network option. Its installation, authentication, and SSH authorization are separate steps. Join the tailnet interactively, then use tailscale set --ssh=true only if Tailscale SSH is wanted. The tailnet must also authorize the connection in its SSH policy. Do not use tailscale up --reset to change one setting on an existing machine.
This export does not rewrite the current host's firewall, SSH policy, account membership, or credentials. Review those changes separately before applying a new-host profile.
Agents can reach an operator Mac with ssh mac. They use it to open links in the operator's browser and to control Mac apps. This is full control of the Mac as the Mac user: agents can pull things up in front of you, fetch any file, run commands, drive apps, and read and send messages. Turn it on only for a Mac that you accept that for. Crewship configures the host side. You configure the Mac side by hand, one time. Keep the Mac's name, address, and login out of this repository.
Set the Mac's address and login in .local/host.yml only, never in blueprint/config/default.yml:
crewship:
mac_ssh:
host: <Mac tailnet name or IP>
user: <Mac login>When mac_ssh is not set, apply skips this step. When it is set, apply does three things as the Crewship account:
- It generates
~/.ssh/id_ed25519_macwithssh-keygen(fromopenssh-client) if the file does not exist. It never replaces an existing key. Do not copy this key to another host; each host gets its own. - It writes a
Host macentry betweencrewship Host macmarkers at the top of~/.ssh/config, withIdentitiesOnly yesandConnectTimeout 5. It does not change other entries. - It writes a line for the Mac's
~/.ssh/authorized_keysto~/.ssh/id_ed25519_mac.authorized_keysand prints it. The line is restricted withfrom="<this host's tailnet IP>", so the key works only from this host. If the host is not on the tailnet yet, the line has a placeholder. Join the tailnet and run apply again to get the address.
Apply does not change the Mac.
-
Install Tailscale on the Mac and on the host, and sign in to the same tailnet on both. Use the Mac's tailnet name or tailnet IP as
mac_ssh.host. -
On the Mac, open System Settings > General > Sharing, and turn on Remote Login.
-
Append the line from the host to the Mac's
~/.ssh/authorized_keys. Copy the output ofcat ~/.ssh/id_ed25519_mac.authorized_keyson the host. On the Mac, run:mkdir -p ~/.ssh && chmod 700 ~/.ssh printf '%s\n' '<the line from the host>' >> ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys
The line holds only a public key. Do not put the private key ~/.ssh/id_ed25519_mac on the Mac.
With remote debugging turned on in chrome://inspect, a Chromium browser shows an "Allow remote debugging?" prompt for each new CDP connection. Only a person can click it. A browser started with --remote-debugging-port serves CDP on 127.0.0.1 with no prompt. Dia, a non-Google Chromium browser, allows the flag on its main profile.
tools/dia-debug/dia-debug runs every 15 seconds from a user LaunchAgent. When the browser runs without the flag and started less than 90 seconds ago (from the Dock, a link, login, or a self-update), the script quits it with SIGTERM and opens it again with the flag. SIGTERM is Chromium's graceful quit, so the browser restores the session. The script tries one time per browser process, so it never takes away a window that is in use. dia-debug --now relaunches the browser at any age. Another non-Google Chromium browser works after you change BUNDLE at the top of the script.
To install, run this on the Mac from a copy of this repository:
mkdir -p ~/.local/bin ~/Library/LaunchAgents
cp tools/dia-debug/dia-debug ~/.local/bin/
cp tools/dia-debug/local.dia-debug.plist ~/Library/LaunchAgents/
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/local.dia-debug.plist
~/.local/bin/dia-debug --nowTo verify, run curl -s http://127.0.0.1:9222/json/version on the Mac. On the host, run ssh -N -L 19222:127.0.0.1:9222 mac. Then connect to the webSocketDebuggerUrl from curl -s http://127.0.0.1:19222/json/version, with port 9222 changed to 19222.
To remove, run this on the Mac, then quit and open the browser again:
launchctl bootout gui/$(id -u)/local.dia-debug
rm ~/.local/bin/dia-debug ~/Library/LaunchAgents/local.dia-debug.plistRisk: any local process on the Mac can control the signed-in browser without a prompt. The port is bound to 127.0.0.1 only.
After ssh mac works, ship.sh launch offers this step once, with its own marker ~/.local/share/crewship/dia-cookies-offer-done, even when the new-host questions are already done. Without a terminal it prints a hint to set mac_ssh.dia_cookies in host.yml. The answer is off unless you choose it. It needs the debug-port setup above, Python with websocket on the Mac, and at least one open tab in each Dia profile to export.
crewship:
mac_ssh:
host: <Mac tailnet name or IP>
user: <Mac login>
dia_cookies: trueWhen mac_ssh.dia_cookies is true, apply installs tools/dia-cookies/dia-cookies to ~/.local/bin, installs python3-cryptography, and enables the user timer dia-cookies.timer (every 30 minutes). Apply does not read the Mac. The timer runs dia-cookies refresh: it reads each profile's cookies through the debug port and keeps them on this host only. The files are mode 0600, encrypted with a key in ~/.config/dia-cookies/fernet.key. Crewship never commits or uploads them, and apply and the unit never print cookie values.
dia-cookies list shows profiles and ages. dia-cookies list <profile> shows cookie names, never values. dia-cookies get <profile> -o FILE writes a mode 0600 file, and -o - prints values to stdout. A profile with no open tab keeps its previous export and refresh exits 3, which the unit accepts; any other failure exits 1 and fails the unit.
To remove it, set dia_cookies to false, run systemctl --user disable --now dia-cookies.timer, and delete ~/.local/share/dia-cookies and ~/.config/dia-cookies.
Skip this part if agents only open links. To let an SSH session focus apps and type with osascript and System Events, give two permissions to /usr/libexec/sshd-keygen-wrapper. Every SSH session on the Mac runs under this program.
- Open System Settings > Privacy & Security > Accessibility. Click
+, press Command-Shift-G, type/usr/libexec/sshd-keygen-wrapper, and add it. Turn it on. - Do the same in Privacy & Security > Full Disk Access.
Screen Recording is a separate permission. Without it, screencapture over SSH fails. Add the same program in Privacy & Security > Screen Recording only if agents must take screenshots.
On the host, as the Crewship account:
ssh mac true && echo okThe first connection asks you to accept the Mac's host key. Compare the fingerprint with the output of ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub on the Mac. To test app control, run ssh mac "osascript -e 'tell application \"System Events\" to get name of first application process whose frontmost is true'". It prints the name of the app in front.
The person at the Mac uses the same screen and keyboard. Keystrokes go to the app that is in front at that moment.
- Focus an app by its bundle identifier:
ssh mac open -b com.apple.Safari. Do not rely ontell application "…" to activate; it can fail and leave another app in front. To find a bundle identifier, runosascript -e 'id of app "Safari"'on the Mac. - Before each keystroke, read the bundle identifier of the app in front, and stop if it is not the expected app:
ssh mac "osascript -e 'tell application \"System Events\" to get bundle identifier of first application process whose frontmost is true'". Typing takes focus away from the person at the Mac, and text can go into the wrong window. - To open a link, use
ssh mac open '<url>'. It does not need app control.
A new host gets its own key; never copy ~/.ssh/id_ed25519_mac from the old host.
- Run apply on the new host with the same
mac_sshvalues. It generates a new key and writes the new line. - Add the new line to the Mac's
~/.ssh/authorized_keys: at the Mac, as in step 3 of the setup, or from a host that already has access:ssh mac 'cat >> ~/.ssh/authorized_keys' < new-host.authorized_keys, wherenew-host.authorized_keysis a copy of the new host's line file. The line is public, so you can copy it withscp. - Run
ssh mac trueon the new host. - At cutover, remove the old host's line from the Mac's
~/.ssh/authorized_keys. Each line ends with the comment<user>@<hostname>, the project name and the wordmac; the hostname identifies the host. A key made before the Crewship rename carries the earlier project name. Keep the old line until the new host works.
The other direction, from the operator's Mac to the host, is also a manual setup on the Mac. Apply does not change it. Every host gets mosh (mosh-server) in the base packages.
Add a Host alias for the host to ~/.ssh/config on the Mac. Set User to the host's Crewship account, so ssh <alias> and mosh <alias> log in as that account without user@:
Host <alias>
HostName <host tailnet name or IP>
User <Crewship account>
mosh reads the alias too, because it starts its session over ssh.
Run these commands on the Mac:
ssh <alias>
mosh <alias> -- herdr-patchOver mosh explains herdr-patch. Keep the alias, the host's address and the account name out of this repository.
A test must never reach the live Herdr or TUIOS session or a host daemon. A no-mistakes test step once ran tuios kill-session against the live socket and ended the owner's session. The agents profile installs ~/.local/bin/cf-sandbox (from blueprint/maintenance/cf-sandbox) and the bubblewrap package, and it runs a command like this:
cf-sandbox [--no-net] [--bind PATH] [--ro-bind PATH] [--cwd DIR] -- COMMAND [ARG...]Inside the sandbox the command has its own pid, IPC and UTS namespaces, so it cannot signal a host process. HOME, XDG_RUNTIME_DIR and /tmp are private directories under $TMPDIR (set CF_SANDBOX_SCRATCH to move them); they are removed on exit. The real home and runtime directory hold the live sockets and are not mounted. /run is empty, so the Docker socket and the user bus are gone. The variables HERDR_*, TUIOS_*, DBUS_SESSION_BUS_ADDRESS, SSH_AUTH_SOCK, DOCKER_HOST and PI_CONFIG_FILES are dropped. /usr, /etc and the system libraries are read-only. The checkout is read-write, and cf-sandbox refuses to start when the checkout is or contains the real home or runtime directory; in a git worktree the shared git directory is read-only. Toolchains in the real home (.cargo, .rustup, .local/bin, .local/share/uv, .local/share/code-factory, .omp/puppeteer, .bun, .nvm, .pyenv) are read-only (the bun package cache target is mounted read-only too), and the uv, sccache and cargo registry caches are read-write. Nothing else of the disk is mounted, because a read-only bind does not stop a connect() to a Unix socket. Add a path with --bind (read-write) or --ro-bind, or with CF_SANDBOX_RW and CF_SANDBOX_RO (colon-separated).
The network is shared unless you pass --no-net. Abstract Unix sockets belong to the network namespace, so use --no-net for a test that needs no network. This repository's own test step leaves the network shared, because one test fetches a release page from the registry. The sandbox gets a git identity of its own and no GitHub credentials.
How to use it:
- Workers: run every test, lint or build command that is not a plain read-only check as
cf-sandbox -- <command>, from inside the worktree. This applies to any test that starts, stops or lists sessions. - no-mistakes: this repository's
.no-mistakes.yamlsetscommands.testtoscripts/test-affected, which runs pytest undercf-sandbox --. no-mistakes has no global setting that wraps the test command of another repository (its host-levelrepository_overrides.<remote>.commands.<step>acceptsniceonly), so add the samecf-sandbox --prefix to thecommands.testof each repository you validate on the host. - Real Herdr work still goes through
tests/herdr-labon a named lab session; the sandbox does not replace it.
tests/test_cf_sandbox.py proves the boundary with fake sockets: a client that sends kill-session reaches a fake daemon outside the sandbox and none inside it.
With profiles.koncreet on, every apply on a host that starts services (not the container worker image) installs Koncreet as /usr/local/bin/koncreet and renders /etc/koncreet.conf once, but nothing runs it. Koncreet is optional: when its release lookup, checksum, or download fails, apply prints a warning, skips it, and finishes the rest; a release installed earlier stays in place. It is a first-hour hardening toolkit: a sudo user with SSH keys, sysctl, swap, a journald cap, time sync, a ufw default-deny firewall, fail2ban on SSH, unattended security updates, and finally SSH with password and root login turned off.
Upstream supports Debian 12/13 and Ubuntu 22.04/24.04 only. blueprint/patches/koncreet/ubuntu-26.04.patch adds Ubuntu 26.04: it opens the OS gate and doctor, and restores the last fallback Koncreet uses to find your SSH client address for the fail2ban whitelist: 26.04 keeps no utmp, so who -m prints nothing, and the patch asks logind instead. The Ubuntu 26.04 change now lives in that patch file, which is the source of truth; upstream is jimididit/koncreet. Apply layers the patch on each new release and prints which case it hit: applied; skipped because the release already supports 26.04; or skipped because it no longer applies, in which case Koncreet installs as released and refuses to run on 26.04 until the patch is refreshed. The patch never fails the apply.
/etc/koncreet.conf makes the account that ran ./ship.sh launch the sudo user, installs the SSH keys it logs in with, and keeps SSH open (Koncreet always allows the ports sshd listens on). With the tailscale profile it also opens 41641/udp for Tailscale's direct connections. When apply ran as root, or as the Crewship account (which runs the agents and must not gain sudo), no sudo user is set: user= and pubkey_file= stay commented out until you fill in the operator's login. Apply never overwrites it; edit it there.
Run these commands once, by hand, on the server. Keep the SSH session open until the last step works:
- With the
tailscaleprofile:sudo ufw allow in on tailscale0, so the tailnet stays reachable once ufw denies incoming traffic. Koncreet keeps existing ufw rules. sudo koncreet doctorsudo koncreet --dry-run apply -c /etc/koncreet.conf, and read the plan.sudo koncreet apply -c /etc/koncreet.conf- Open a new SSH session as that user and run
sudo true. Only when it works:sudo koncreet ssh apply. Test one more new session before you close the first. Notsudo -v: once the account is in thesudogroup,sudo -vasks for a password even when sudoers grants it NOPASSWD, and a cloud account has none.
If something goes wrong (from upstream's README):
| Problem | Fix |
|---|---|
| Can't SSH after harden | sudo koncreet ssh undo |
| Locked out by ufw | Console: sudo ufw disable |
| Banned by fail2ban | sudo koncreet fail2ban unban YOUR.IP |
| Undo baseline drop-ins | sudo koncreet baseline undo (keeps users/swap/timezone) |
| Need the new user password | cat /root/USER.koncreet-password (as root - save it before ssh apply) |
| Forced password change fails | chage -d $(date -I) USER then reconnect with your key |
| Too many authentication failures | ssh -o IdentitiesOnly=yes -i ~/.ssh/your_key user@host |
Logs: /var/log/koncreet.log. Backups: *.koncreet.bak. The provider's console, and tailscale ssh where Tailscale SSH is enabled, reach the host when sshd does not.
See Dependencies for tool release selection, download verification, and exceptions. Checksums prove a download is the published artifact; they do not establish that a publisher is trustworthy. Review added tools and installer behavior before adding them. Ubuntu security updates remain an operating-system responsibility rather than freezing an entire vulnerable package index forever.
Back up project repositories and application data separately, using encrypted storage and an application-aware restore procedure. A successful environment bootstrap is not evidence that a database backup is recoverable.