Skip to content

Security and Trust

What Barn runs as root, what it does with SSH keys and ~/.ssh/config, what a guest can reach on your host, and how to verify releases and images.

Read this before letting Barn run VMs on your workstation: what it does as root, what it does with your SSH setup and files, and how to check that a download is genuine.

Barn assumes a single-user development machine. Its ownership and process-identity checks keep it from damaging unrelated files and processes by mistake; they are not a barrier against another hostile user on the same host. Inside a Linux lab the nodes trust each other: they share a private subnet, and the control node holds a key to every peer.

What Barn runs as root

Run barn as your normal user. QEMU processes, Barn.app VMs, the image cache, disks, keys, and state all belong to your account under $BARN_HOME. Only three host-wide changes need sudo, and each prints its plan before asking:

CommandWhat runs as root
barn setup (Linux)The system package manager (apt-get or dnf) installs QEMU, firmware, and OpenSSH. On macOS, Homebrew runs as your user
barn network install / uninstallCreates or removes the host-wide fixed-IP network: the barn0 bridge on Linux, the socket_vmnet launchd service on macOS
barn hosts install / uninstallbarn-hosts-helper rewrites only Barn’s marker-delimited block in /etc/hosts

They are separate commands so you can review and run each one yourself. On a terminal, up, start, restart, and reload offer the same setup plan when a dependency or the Barn network is missing; without a terminal they only report it. Unattended preparation is covered in barn setup.

barn-hosts-helper is the only component that writes /etc/hosts, so keep it and barn from the same build. The CLI runs /opt/barn/libexec/barn-hosts-helper only if its SHA-256 matches the digest compiled into the CLI, and the helper checks the file’s ownership, permissions, link count, and content digest before and after writing. A substituted helper never gets root, and a plan reviewed against an older /etc/hosts cannot overwrite newer edits.

barn mac needs no root at all: each macOS VM’s private network is created in user space by its own runner process.

Your SSH keys and ~/.ssh/config

Barn generates its own keys and leaves yours alone:

  • A Linux lab uses one Ed25519 deployment keypair under $BARN_HOME, shared by all nodes.
  • Each macOS VM has its own Ed25519 keypair in its directory under $BARN_HOME/mac.

Every SSH session Barn opens (barn ssh, barn exec, barn mac ssh, and the rest) runs OpenSSH with -F /dev/null, Barn’s key, and Barn’s own known_hosts. Your ~/.ssh/config, personal keys, and ~/.ssh/known_hosts play no part.

So that plain ssh meta or ssh mac1 also works, Barn adds one marked Include block to ~/.ssh/config pointing at a fragment it owns: ~/.ssh/barn_config for the Linux lab and ~/.ssh/barn-mac_config for Mac VMs. Each block is edited only by its owner. If ~/.ssh/config is a symlink or hard link, as with many dotfile managers, Barn leaves it untouched, writes the fragment, and prints the Include line for you to add. A Host you already defined with a Mac VM’s name keeps your definition; Barn publishes that VM by IP address only.

Whole-deployment destroy and purge remove the Linux integration. To remove either one yourself:

barn ssh-config --remove
barn mac ssh-config --remove

Guest accounts and host keys

Every guest accepts SSH public keys only: password authentication and root login are disabled, and the admin account has passwordless sudo.

  • Linux: the login account defaults to dba and can be set with node_admin_username. Its password is locked. Barn also installs the deployment private key on the control node (admin_ip) so Ansible and Pigsty playbooks can reach every peer. Anyone with a shell on the control node can therefore administer the whole lab.
  • macOS: each VM also gets a random login password for the lock screen and GUI administrator prompts, kept in a mode 0600 password file next to the VM’s SSH key; barn mac password shows it. It stays out of Keychain because the key beside it already grants sudo, so Keychain would add signing and lock-state failures without protecting anything more (design note).

Each connection path pins host keys differently:

ConnectionHost-key policy
Host → Linux guest (barn ssh, ~/.ssh/barn_config)StrictHostKeyChecking accept-new against Barn’s private known_hosts, keyed by the VM’s UUID. The first connection pins the key and a later mismatch is rejected. recreate gives the VM a new UUID, so a rebuilt node never hits a stale entry
Linux control node → lab peersStrictHostKeyChecking no and UserKnownHostsFile /dev/null for Barn-managed peer aliases, so playbooks keep working after nodes are recreated
Host → macOS guest (barn mac, ~/.ssh/barn-mac_config)StrictHostKeyChecking yes against the VM’s own known_hosts, keyed by barn-mac-<instance_id>, with agent forwarding off. The first key is accepted only over the runner’s private network, with the runner’s identity checked before and after the connection, and is then pinned

What a guest can reach on your host

A guest sees host files only through shares you configure, and only a macOS guest shares the clipboard:

ChannelLinux guestmacOS guest
Host directoriesvm_shares entries over Virtio-9p, read-only unless readonly: false (shares)--share entries over VirtioFS, writable unless suffixed :ro (shared folders)
ClipboardNone; Linux guests run headlessPlain text up to 1 MiB each way, while the VM window has focus; on by default (clipboard)

A writable share lets guest processes change the host directory directly, and those changes outlive the VM. Share a dedicated project folder, and use read-only shares when the guest only needs to read. The clipboard never sends items that password managers mark as concealed or transient, and it never carries images or files. Turn it off for a VM with barn mac configure <name> --clipboard off (from its next start), or for the current session with Machine → Share Clipboard.

Each Linux node’s management SSH port is forwarded on host 127.0.0.1 only. Data disks hold test data: during recovery Barn may reformat a corrupted filesystem, persistent disks included, so keep anything valuable on the host (when Barn resets a data disk).

Verify releases and images

Each object Barn downloads has its own check:

ObjectVerification
Release assetsThe installer checks the archive against checksums.txt. Verify the detached ML-DSA-87 signature checksums.txt.sig with the official release key to authenticate the checksum list.
Apple Silicon binariesThe release CLI, helper, and Barn.app carry Developer ID signatures and Apple notarization, and the app has a stapled ticket. Local native builds use ad-hoc signing by default
Image catalogOfficial and plain HTTP repositories require a signature from a key embedded in barn. The highest accepted revision is tracked per repository. An intentional rollback requires barn image sync --allow-downgrade
Image filesDownloads must match the catalog’s byte size, SHA-256, and virtual size. Local imports compute the file’s digest and compare it with --sha256 when supplied. Both paths validate the standalone qcow2 format

To check downloaded release assets yourself, run this in the download directory:

shasum -a 256 -c checksums.txt --ignore-missing

Because the signed catalog pins every image by digest, a mirror cannot substitute an image, and the revision check stops it from replaying an older catalog. The official repositories, https://repo.pigsty.io/barn and https://repo.pigsty.cc/barn, always require a valid signature, even when named with --repo. A custom HTTPS or local repository may serve an unsigned catalog, but only when you select it with --repo or BARN_REPO, so add only sources you trust (Linux Images).

The draft records signed:false. The release owner signs the final checksum manifest, which covers release.json with signed:true. Verify the signature · Release gates

Report a vulnerability

Report vulnerabilities privately through GitHub private vulnerability reporting or by email to [email protected], not in a public issue. Include barn --json version, your host OS and architecture, and the smallest reproduction you have, with private keys and passwords removed. You should get an acknowledgement within five working days.

Security fixes ship in the latest 1.x patch release. Only the latest 1.x release is supported; 0.x releases receive no further fixes. The full policy is in SECURITY.md; ordinary bugs go to GitHub Issues.

Table reader