Automate Hermitbox: CLI, Shortcuts and links
Automate Hermitbox with the hermitbox CLI, hermitbox:// links and Shortcuts: every command, exit codes, name matching, and what automation can't do.
Updated 7 min read
On this page
This page shows you how to control Hermitbox VMs without clicking: with the Hermitbox CLI (the hermitbox command-line tool), hermitbox:// links and Shortcuts actions. It also covers how VM names are matched, what the exit codes mean, and what automation can't do.
All three work through the Hermitbox app. If Hermitbox isn't running, the command-line tool opens it in the background.
Install the Hermitbox CLI
The tool ships inside the app at Hermitbox.app/Contents/Helpers/hermitbox. Installing it puts a link to it in a folder on your PATH.
- Open Hermitbox and choose Hermitbox ▸ Settings… (⌘,).
- Click the Advanced tab.
- Under Command line tool, pick a location:
~/.local/bin(the default). No password needed./usr/local/bin. This folder needs an administrator.
- Click Install.
If you chose /usr/local/bin and Hermitbox can't write there, it shows "That folder needs an administrator. Copy the command and run it in Terminal." Use Copy Command (or Run in Terminal) and enter your password in Terminal. The command is a sudo ln that creates the link.
The status line under the setting tells you where you stand:
| Status | Meaning |
|---|---|
| "Installed. Try “hermitbox list”." | Ready to use. |
| "Installed. Make sure ~/.local/bin is in your PATH." | The link exists, but your shell may not find it yet (see below). |
| "Points to another copy of Hermitbox. Install to use this one." | The link goes to a different copy of the app. Click Install to point it at this one. |
| "Another file named hermitbox is already there." | Some other file with that name is in the way. Move it, or pick the other location. |
To remove the tool, click Remove in the same place.
Add ~/.local/bin to your PATH
macOS doesn't include ~/.local/bin in PATH by default. With zsh (the default shell on current macOS), run:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrcThis appends one line to ~/.zshrc. Open a new Terminal window for it to take effect. To undo it, delete that line from ~/.zshrc.
Check that it works:
hermitbox versionHermitbox CLI command reference
Run hermitbox help to see this list in Terminal.
| Command | What it does |
|---|---|
hermitbox list [--json] | Lists your VMs and their state. Alias: ls. |
hermitbox start NAME [--headless] [--disposable] | Starts or resumes a VM. |
hermitbox stop NAME [--force] | Shuts the VM down by asking the guest. --force (or -f) pulls the plug, like Force Stop. |
hermitbox suspend NAME | Saves the VM's state to disk and stops it. The next start resumes it. |
hermitbox pause NAME | Freezes the VM in memory. |
hermitbox resume NAME | Resumes the VM. |
hermitbox open NAME | Shows the VM's window. |
hermitbox clone NAME [NEW_NAME] | Makes an instant copy. |
hermitbox snapshot create NAME [SNAPSHOT] | Takes a snapshot. Alias: take. |
hermitbox snapshot list NAME | Lists the VM's snapshots. Alias: ls. |
hermitbox snapshot restore NAME [SNAPSHOT] | Restores a snapshot. Alias: revert. |
hermitbox snapshot delete NAME [SNAPSHOT] | Deletes a snapshot. Alias: rm. |
hermitbox ip NAME | Prints the VM's IP address. |
hermitbox ssh [USER@]NAME [-- [SSH OPTIONS] [COMMAND]] | Connects to the VM with ssh. -l USER works instead of USER@. |
hermitbox version | Prints the version. Also -v. |
--format json|text sets the output format. list --json gives you machine-readable output for scripts.
Rules for start, stop and clone
start --headlessruns the VM without a window. Open its window later withhermitbox open NAMEor from the menu bar.start --disposablestarts a throwaway copy, the same as Run Without Saving Changes: everything that changed is discarded when it stops. You can't combine--disposablewith--headless. A disposable macOS VM counts toward the limit of two macOS VMs at a time.starton a template doesn't start the template itself. It creates a copy named "NAME 2" without asking.stopwithout--forcelets the guest shut down normally.--forceis like pulling the plug, so unsaved work in the VM is lost.cloneneeds the VM shut down or suspended. The copy gets a new id and MAC address, and no snapshots or saved state.
How VM names are matched
Wherever a command takes NAME:
- Matching is case-insensitive:
ubuntumatches "Ubuntu". - A unique prefix is enough:
ubuworks if no other VM name starts with "ubu". If a prefix matches more than one VM, type more of the name. - You can also pass the VM's id.
Quote names that contain spaces:
hermitbox start "macOS 15 Test"Exit codes and error messages
| Code | Meaning |
|---|---|
0 | Success. |
1 | Error. The message is printed to stderr. |
64 | Usage error (wrong command or arguments). |
69 | Hermitbox couldn't be reached. |
Messages you may see on stderr:
| Message | What to do |
|---|---|
| "Hermitbox couldn't be opened. Is it installed?" | Make sure Hermitbox is in your Applications folder and opens normally. |
| "Hermitbox opened but didn't answer. Try again in a moment." | Hermitbox was still launching. Run the command again. |
| "No VMs yet. Create one in Hermitbox." | Create a VM in the app first. The CLI can't create VMs. |
| "No IP address yet." | The VM is still starting up. Wait a few seconds and retry. |
| "The control socket belongs to another user." | Run the command as the same macOS user that runs Hermitbox. |
The CLI talks to the app over a private Unix socket at ~/Library/Application Support/Hermitbox/Control/control.sock, which only your user can open. Nothing listens on the network.
Script snapshots and SSH
Take a snapshot before a risky change
hermitbox snapshot create ubuntu "before-upgrade" && echo "Snapshot taken"If the VM is running, Hermitbox suspends it briefly, takes the snapshot and resumes it. On an APFS disk the snapshot is instant and takes no space until the VM changes; on other disks it's a full copy. Snapshots aren't available for disposable runs.
To roll back:
hermitbox snapshot restore ubuntu "before-upgrade"snapshot restore always snapshots the current state first, so a scripted restore never throws away the state you were in. Remove snapshots you no longer need with hermitbox snapshot delete.
Wait for a VM's IP address, then connect
A VM that has just started may not have an address yet. hermitbox ip fails until it does, so you can loop on it:
hermitbox start ubuntu --headless
until ip=$(hermitbox ip ubuntu 2>/dev/null); do sleep 2; done
echo "Ubuntu is at $ip"This loop waits forever if the VM never gets an address, so stop it with Control-C (⌃C) if it hangs.
Then run a command in the VM over SSH:
hermitbox ssh dev@ubuntu -- uptimeEverything after -- goes to ssh: options first, then the command to run in the VM. Leave it out to get an interactive session. Hermitbox stores no SSH passwords; ssh handles authentication with your keys as usual.
Start, test, stop
#!/bin/zsh
hermitbox start build-box --headless || exit 1
until hermitbox ip build-box >/dev/null 2>&1; do sleep 2; done
hermitbox ssh build-box -- ./run-tests.sh
result=$?
hermitbox stop build-box
exit $resultThe script saves the test result before shutting the VM down, so the VM stops even when the tests fail, and the script still exits with the tests' exit code.
How hermitbox:// links work
Links let you start or stop a VM from anything that opens URLs: a note, a launcher, a web page, or Terminal with open.
The format is:
hermitbox://ACTION?name=VMYou can use id= or vm= instead of name=.
| Action | What it does |
|---|---|
start | Starts or resumes the VM. Add &headless=1 to run it without a window. |
open | Shows the VM's window. |
stop | Shuts the VM down. Alias: shutdown. |
suspend | Saves the state and stops the VM. |
pause | Freezes the VM in memory. |
resume | Resumes the VM. |
Examples:
open "hermitbox://start?name=Ubuntu&headless=1"
open "hermitbox://suspend?name=Ubuntu"open hands the link to Hermitbox, the same as clicking it. In a link, write spaces in a VM name as %20 (for example name=macOS%2015%20Test).
Links can't force-stop a VM, take snapshots, clone, or start disposable runs. Use the CLI or the app for those. If a link is malformed or asks for something links can't do, Hermitbox shows an alert that says why.
Shortcuts actions
Hermitbox adds these actions to the Shortcuts app. The VM parameter is searchable by name.
| Action | Parameters | What it does |
|---|---|---|
| Start Virtual Machine | VM; Show Window (on by default) | Starts or resumes the VM. Turn off Show Window to run it in the background. |
| Shut Down Virtual Machine | VM; Force Stop (off by default) | Shuts the VM down, or pulls the plug if Force Stop is on. |
| Suspend Virtual Machine | VM | Saves the state and stops the VM. |
| Take Snapshot | VM; optional Name | Takes a snapshot. |
| Get IP Address of Virtual Machine | VM | Returns the VM's IP address. |
| Get Running Virtual Machines | None | Returns the VMs that are running. |
Hermitbox also registers App Shortcuts, so you can ask Siri with phrases such as "Start a VM in Hermitbox".
For example, chain Start Virtual Machine with Show Window off, then Get IP Address of Virtual Machine, then Copy to Clipboard to start a server VM and have its address ready to paste.
What automation can't do
- Create VMs. There's no
createcommand, link or Shortcuts action. Create VMs in the app with File ▸ New VM… (⌘N), then automate them. - Change VM settings. Cores, memory, disks, display, network and sharing are changed in the app, in the VM Settings window or the inspector.
- Use AppleScript. Hermitbox has no AppleScript dictionary. From AppleScript you can call the CLI with
do shell script, using the tool's full path (for example~/.local/bin/hermitbox list), because it doesn't read your shell'sPATH. - Force-stop, snapshot, clone or start disposable runs from links. The CLI can do all of these. Shortcuts can force-stop and take snapshots.
- Control Hermitbox from another device. There's no network server, web dashboard or iOS app. The CLI only talks to Hermitbox on the same Mac, as the same user.
- Get around Apple's limits. Automation follows the same rules as the app, including the limit of two macOS VMs running at once.