Skip to content
Back to skills

Horizon Machines

FSecurity

Rent, prepare, connect to, stop, and tear down remote Linux machines and GPU pods from your own shell using the user's already-authenticated provider CLIs (hcloud, aws, gcloud, az, runpodctl), manage Horizon's live Machines sidebar and remote tmux panels through the public machine MCP tool, and optionally join machines to a Tailscale network. Use it when the person asks to spin up a cloud VM or GPU pod, check or clean up rented machines, open a machine panel in Horizon, or attach a rented mac...

  • 726 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 4, 2026
ai-agentsrustgoshellawsgcpazureapisecurity

Works with

  • cli
  • api
  • mcp

Security analysis

F25/100
  • criticalAccesses sensitive system or user directories
  • criticalAccesses sensitive system or user directories
  • criticalAccesses sensitive system or user directories

Pro scans all 7 files and shows the line behind each finding

Scanned December 4, 2026

npx -y skills add peters/horizon --skill horizon-machines --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Horizon Machines?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Horizon Machines
[![Security: F — Skills Directory](https://www.skillsdirectory.com/api/skills/peters-horizon-machines/badge)](https://www.skillsdirectory.com/skills/peters-horizon-machines)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: horizon-machines
description: >-
  Rent, prepare, connect to, stop, and tear down remote Linux machines and GPU pods from your
  own shell using the user's already-authenticated provider CLIs (hcloud, aws, gcloud, az,
  runpodctl), manage Horizon's live Machines sidebar and remote tmux panels through the public
  machine MCP tool, and optionally join machines to a Tailscale network. Use it when the person
  asks to spin up a cloud VM or GPU pod, check or clean up rented machines, open a machine panel
  in Horizon, or attach a rented machine to Tailscale. Never prints provider credentials, never
  modifies global CLI contexts, and always confirms paid creation or deletion first.
---

# Horizon machines

Use this skill to rent, prepare, register, open, and delete remote Linux
machines using the provider CLIs that the person already installed and
authenticated on this computer, together with Horizon's public `machine` MCP
tool (`--browser-mcp`).

## The `machine` MCP tool

`machine` operations are `set`, `remove`, `list`, and `open`.

- **`set`** registers or partially updates a machine in
  `${HORIZON_HOME:-$HOME/.horizon}/machines.json` (mode `0600`) with required
  `name` and `host`, plus optional `user`, `port`, `identity_file`,
  `known_hosts_file`, `folder`, `provider`, `size`, `place`, `price_per_hour`,
  `task` (short status/purpose label shown on the sidebar row, up to 64
  printable characters), and `started_at_millis` (Unix epoch milliseconds for
  live uptime and accrued cost in the sidebar **Machines** section). Updating an
  existing machine (case-insensitive `name` match) merges fields: omitting an
  optional field preserves its stored value, passing `""` clears an optional
  string field (`user`, `identity_file`, `known_hosts_file`, `folder`,
  `provider`, `size`, `place`, `price_per_hour`, `task`) to unset, omitting
  `port` preserves any stored port (`port: 0` is rejected), and omitting
  `started_at_millis` auto-stamps the current wall clock on a new machine with
  `price_per_hour` or `task`, preserves it on updates, and clears it to unset
  when passed `0` (negative values are rejected). When `started_at_millis` is
  set, the sidebar **Machines** row shows live elapsed runtime (and accrued cost
  such as `24m · $0.24` when `price_per_hour` parses as a numeric rate) and
  keeps the hourly rate and full spec in the hover tooltip.
- **`remove`** removes a registered machine by `name` from `machines.json`.
- **`list`** returns all registered machines from `machines.json`.
- **`open`** focuses an existing SSH panel matching `(name, session)` or opens
  a new `tmux` SSH panel in the active workspace (`preset` defaults to `shell`
  and accepts `shell`, `claude`, `codex`, `open_code`, `agy`, `kilo_code`,
  `pi`, `grok`; optional `folder` overrides any workspace **Remote folder** or
  machine default folder for that panel without mutating `machines.json` or the
  workspace's **Remote folder**; when `session` is omitted, passing `preset` or
  `folder` opens a new `tmux` panel instead of focusing an existing one; set
  `place_workspace: true` to place the active workspace on that machine,
  preserving any per-workspace **Remote folder** override already set for the
  same machine and resetting it when switching machines; `session` must match
  `[a-z0-9_-]+`).

A person can also add or remove any discovered SSH config or Tailscale host in
Horizon's **Remote Hosts** overlay (**Pin to Machines** / **Remove from
Machines**, or `Alt+P`) so it joins `machines.json` and the watched sidebar
**Machines** section without editing JSON by hand.

When an agent runs inside a Horizon panel or when one Horizon window runs in
the same Horizon home, `set`, `remove`, and `list` notify the live Horizon host
so the sidebar **Machines** section, workspace **Place** menu, and **Remote
Hosts** overlay update immediately (`live_host_notified: true`). When zero or
multiple Horizon windows run, `set`, `remove`, and `list` still update
`machines.json` atomically (`live_host_notified: false`), while `open` refuses
with `host_unavailable` or `ambiguous_host`. Never pass credentials or secrets
through `machine`; pass only per-machine key file paths and isolated
`known_hosts` paths.

## Workspace placement and per-workspace remote folders

Placing a workspace on a machine makes new `Shell`, `Command`, and CLI agent
panels in that workspace open over `ssh` inside deterministic `tmux` sessions on
that host without a local folder prompt.

- **Per-workspace folder override and 3-level precedence:** Multiple workspaces
  placed on the same machine can target separate remote directories via the
  workspace's **Remote folder** override. When opening a remote `tmux` panel,
  Horizon resolves `tmux new-session -c <dir>` with strict precedence:
  1. `machine(open, folder: "<path>")` explicit per-launch override,
  2. the workspace's **Remote folder** override (when placed on that machine),
  3. the machine's default `folder` in `machines.json`.
- **UI configuration (not `machine` MCP):** Configure or clear a workspace's
  **Remote folder** from the workspace **Place** menu in Horizon's UI
  (right-click the workspace row in the sidebar or the workspace header pill on
  the board, edit **Remote folder**, and press `Enter` / click **Apply**, or
  click **Clear**). The `machine` MCP tool manages the machine-level default
  `folder` (`set`) and one-off panel launch overrides (`open` `folder`), not
  persistent per-workspace overrides. When a workspace override is set, the
  workspace header pill displays `· <machine> · <basename>` with
  `<machine>:<folder>` on hover.
- **Validation:** Both UI input and saved session files require an absolute
  POSIX path starting with `/`, `1..=512` characters, and zero control
  characters or NUL bytes (`validate_remote_folder`), single-quoted via
  `posix_quote` before `tmux new-session -c`.
- **Lifecycle across placement changes:** Re-placing a workspace onto the same
  machine (from **Place**, **Remote Hosts**, the sidebar **Machines** menu, or
  `machine` `open` with `place_workspace: true`) preserves its **Remote folder**
  override; switching to another machine resets the override to `None`, and
  switching to **This computer** resets placement to local.

## Sidebar SSH port forwarding

Right-clicking a registered machine row in the sidebar **Machines** section
offers **Forward port to Browser…**, opening an inline port prompt beneath that
row (`:3000`, `:5173`, `:8080`, `:6006` presets or any TCP port `1..=65535`).

- **Loopback-only `ssh -N -L` tunnel:** Clicking **Forward & Open** starts a
  non-interactive `ssh -N -L 127.0.0.1:<local>:127.0.0.1:<remote>` child process
  (`BatchMode=yes`, `StrictHostKeyChecking=yes`, `ExitOnForwardFailure=yes`, up
  to 16 active forwards). Horizon binds `127.0.0.1:<remote>` when free locally
  and remaps to an ephemeral `127.0.0.1:<local>` port (`:<remote> → :<local>`)
  when `<remote>` is already in use.
- **Local `Browser` panel and sidebar sub-rows:** Once `127.0.0.1:<local>`
  accepts TCP, Horizon shows an indented forward sub-row under the machine row
  and opens or focuses a local `Browser` panel (`follows_browser_host: false`)
  at `http://127.0.0.1:<local>`. Clicking an active sub-row focuses or reopens
  that local `Browser` panel; clicking `×` or right-clicking **Stop port
  forward** stops the tunnel.
- **Lifecycle and UI-only scope:** Horizon stops and reaps `ssh -N` tunnels when
  stopped in the sidebar, when the machine is removed or its SSH route (`host`,
  `port`, `user`, `identity_file`, `known_hosts_file`, or `proxy_jump`) changes
  in `machines.json`, or when Horizon exits. Port forwarding is a UI-only
  sidebar action, not an operation on the `machine` MCP tool.

## Background `tmux` session watcher

By default (`features.watch_machine_sessions: true`), Horizon opens one
persistent background `ssh ... sh` connection per registered machine in
`machines.json` (`BatchMode=yes`, `StrictHostKeyChecking=yes`, polling `tmux`
and `ps` every 2 seconds, or every 30 seconds when no `tmux` server is running).

- **Live sidebar sub-rows and one-click attach:** Each watched machine shows its
  validated `tmux` sessions beneath its row in the sidebar **Machines** section,
  with agent attention badges (**Needs you**, **Done**, **Working**) when a
  supported coding agent or `@horizon_state` pane runs inside a session.
  Clicking a session row focuses an already-attached panel or opens a new SSH
  `tmux` panel attached to that session.
- **Unfocused desktop notifications:** When an unattached remote agent
  transitions to **Needs you** or **Done** while no Horizon window has focus,
  Horizon sends a desktop notification honoring **Settings > General > Features >
  Desktop notifications** (skipping sessions that already have a local panel
  attached).
- **Setup requirements and limits:**
  - The remote host key must already be trusted in the machine's
    `known_hosts_file` (or `~/.ssh/known_hosts` when unset). Because the watcher
    never accepts unknown keys automatically, an untrusted host shows **Host key
    not trusted** and a mismatched key shows **Host key changed**.
  - Key authentication must succeed non-interactively; otherwise the sidebar
    shows **Auth failed**.
  - Horizon watches up to 8 registered machines concurrently; extra machines
    show **Watch limit reached**.
  - Turn background watching off at **Settings > General > Features > Watch
    remote tmux sessions** (`features.watch_machine_sessions: false`); zero
    watcher threads or `ssh` processes run when disabled or when no machines are
    registered.

## The model

- **User-authenticated CLIs only.** Every provider call uses the CLI already
  authenticated by the person (`hcloud`, `aws`, `gcloud`, `az`, `runpodctl`).
  Never ask the person to paste API keys, tokens, or passwords into chat, never
  print credentials, and never modify global CLI defaults (`gcloud config set`,
  `az account set`, `~/.aws/config`, `~/.aws/credentials`). Pass account,
  project, subscription, region, and profile flags explicitly per command.
- **Explicit approval before cost or deletion.** Always run read-only
  preconditions first (CLI version, active account, available regions/types).
  Present the exact provider, region/zone, machine type (vCPU, memory, GPU if
  requested), estimated price when the CLI reports it (otherwise state that the
  CLI returned no price), and resource name. Wait for explicit confirmation
  before creating paid resources or deleting resources.
- **Mandatory resource labels and naming.** Pick a lowercase machine name
  matching `[a-z0-9-]{1,40}` with no leading or trailing `-` (for example
  `build-1`). Tag every created resource with `horizon-managed=true` and
  `horizon-machine=<name>` (or provider-equivalent name/description prefixes
  where labels are unsupported, as each provider reference specifies) so a
  later session can find and clean up every resource without touching unrelated
  infrastructure.
- **Per-machine SSH key and isolated known-hosts.** Never overwrite or reuse
  the person's default `~/.ssh/id_*` keys, and never add a machine key to a
  shared cloud account key list when avoidable. Generate one dedicated keypair
  per machine:

  ```sh
  NAME=build-1
  KEY_PATH="$HOME/.ssh/horizon-machine-$NAME"
  KNOWN_HOSTS="$HOME/.ssh/horizon-machine-$NAME.known_hosts"
  mkdir -p "$HOME/.ssh" && chmod 700 "$HOME/.ssh"
  ssh-keygen -t ed25519 -N "" -C "horizon-machine-$NAME" -f "$KEY_PATH"
  chmod 600 "$KEY_PATH"
  ```

  Always connect with `-i "$KEY_PATH" -o IdentitiesOnly=yes -o IdentityAgent=none`
  and `-o UserKnownHostsFile="$KNOWN_HOSTS"`. Without `IdentitiesOnly=yes` and
  `IdentityAgent=none`, a local SSH agent holding several keys exhausts
  `MaxAuthTries` and fails with `Too many authentication failures`.
  Delete `"$KEY_PATH"`, `"$KEY_PATH.pub"`, and `"$KNOWN_HOSTS"` after proving
  that the remote machine and its cloud resources are deleted.
- **Never edit `~/.ssh/config` unasked.** Register managed machines through the
  `machine` MCP tool (or atomic `0600` `${HORIZON_HOME:-$HOME/.horizon}/machines.json`
  when Horizon MCP is not connected) so Horizon's sidebar **Machines** section,
  workspace **Place** menu, and **Remote Hosts** overlay discover them without
  touching `~/.ssh/config`. Report the exact `ssh` command, and if the person
  asks for a shell `Host` alias in `~/.ssh/config`, show the block first before
  editing.

## The flow

### 1. Discover available CLIs (read-only)

Check which provider CLIs are installed and signed in before suggesting a
provider:

| Provider | CLI | Read-only check | Reference |
|---|---|---|---|
| Hetzner Cloud | `hcloud` | `hcloud version && hcloud context active && hcloud server list --quiet` | [hetzner](references/hetzner.md) |
| AWS EC2 | `aws` | `aws --profile <p> --region <r> sts get-caller-identity` + `--dry-run` probes | [aws](references/aws.md) |
| Google Cloud | `gcloud` | `gcloud version && gcloud auth list --filter=status:ACTIVE --format="value(account)"` | [gcp](references/gcp.md) |
| Azure | `az` | `az account show -o json --query "{name:name,id:id,state:state}"` | [azure](references/azure.md) |
| RunPod | `runpodctl` | `runpodctl version && runpodctl user -o json` | [runpod](references/runpod.md) |

If a CLI is missing or not signed in, tell the person which login command to run
themselves (`hcloud context create`, `aws configure sso`, `gcloud auth login`,
`az login`, or `runpodctl doctor`). Never run interactive login flows or capture
credentials yourself.

### 2. Inspect regions, types, and existing managed resources (read-only)

Query available regions/zones, machine types, and any existing
`horizon-managed=true` resources using the provider reference. Call `machine`
with `operation: "list"` (or inspect `machines.json`) to see what Horizon
already tracks. Report what is already running before offering to rent anything
new.

### 3. Confirm, generate the per-machine key, and rent

After the person confirms the provider, region/zone, machine type, and name:

1. Generate the per-machine `ed25519` keypair (`~/.ssh/horizon-machine-<name>`).
2. Create the firewall/security group allowing inbound `tcp/22` only (or use
   provider-specific SSH port mapping on RunPod) and create the machine tagged
   with `horizon-managed=true` and `horizon-machine=<name>`.
3. Never create a second machine if a create call times out; inspect the
   provider list first to recover the resource ID.

### 4. Wait for SSH, verify security, prepare `tmux`, and register in Horizon

Poll SSH every 10 seconds for up to 3 minutes:

```sh
ssh -i "$KEY_PATH" -o IdentitiesOnly=yes -o IdentityAgent=none \
    -o UserKnownHostsFile="$KNOWN_HOSTS" -o StrictHostKeyChecking=accept-new \
    -o BatchMode=yes -o ConnectTimeout=10 <user>@<host> 'true'
```

Add `-p <port>` when the provider uses a non-default SSH port (such as RunPod).
Once SSH answers:

1. Verify password authentication is disabled (`sshd -T | grep -i passwordauthentication`
   should report `no`; use `sudo -n` if not root).
2. Check `command -v tmux`; install `tmux` via `apt-get` if absent so long
   commands survive disconnects (`tmux new -A -s "$NAME"`).
3. If the person asks to attach the machine to a Tailscale network, follow
   [tailscale](references/tailscale.md). Never run `tailscale up`, `down`,
   `login`, `logout`, `switch`, or `set` on the person's local computer. If the
   person wants this VM to run as an always-on **Horizon Home** over Tailscale
   (`horizon home`), follow the `horizon-sync` skill after joining Tailscale
   (prefer a full-kernel VM on Hetzner, AWS, GCP, or Azure over a RunPod
   container, which lacks `systemd` and `/dev/net/tun`).
4. Register or update the machine using the `machine` MCP tool so it appears
   immediately in Horizon's sidebar **Machines** section, workspace **Place**
   menu, and **Remote Hosts** overlay:

   ```json
   {
     "operation": "set",
     "name": "build-1",
     "host": "<ip-or-tailscale-host>",
     "user": "<user>",
     "port": 22,
     "identity_file": "/home/<me>/.ssh/horizon-machine-build-1",
     "known_hosts_file": "/home/<me>/.ssh/horizon-machine-build-1.known_hosts",
     "provider": "<provider>",
     "size": "<machine-type>",
     "place": "<region-or-zone>"
   }
   ```

   Include `"folder"` (single clean absolute POSIX path), `"price_per_hour"`, or
   `"task"` (short label of what the machine is doing) when known; omitting
   `"started_at_millis"` on a newly registered machine with `"price_per_hour"`
   or `"task"` stamps the start time automatically so Horizon shows live uptime
   and accrued cost in the sidebar. Later partial `set` calls can update one
   field (such as `"task"` or `"folder"`) without repeating `"identity_file"` or
   facts, or pass `""` to clear an optional string field (`0` clears
   `"started_at_millis"`). If the person asks to open a panel on the machine
   right away, call `machine` with `operation: "open"` (`name`, optional
   `session`, `preset`, `folder`, and `place_workspace`).

   **Fallback when Horizon MCP is not connected:** write or update
   `${HORIZON_HOME:-$HOME/.horizon}/machines.json` (mode `0600`, written
   atomically via a `0600` temp file in the same folder + rename), preserving
   all other entries already in `machines.json`.

### 5. Narrow the SSH firewall (optional)

When the person wants SSH restricted to their current public IP (or closed
entirely after joining Tailscale), update the provider firewall rule to allow
only `<current-ip>/32` (or remove the public `tcp/22` rule only **after**
proving SSH works over the Tailscale address!).

### 6. Stop, start, and delete with proof

- **Stopping does not always stop billing.** Report the provider's exact stop
  billing behavior (for example Hetzner keeps full billing while stopped; Azure
  requires `az vm deallocate` rather than `stop`; AWS/GCP/Azure/RunPod still
  bill attached disks/volumes/static IPs while stopped).
- **Delete in dependency order** (compute before firewall/security group/key or
  template) as documented in each provider reference.
- **Prove cleanup before finishing.** Run the provider's post-delete list
  queries to confirm zero remaining resources for `horizon-machine=<name>`,
  unregister the machine using `machine` with `operation: "remove"` and
  `name: "<name>"` (falling back to an atomic `0600` edit of
  `${HORIZON_HOME:-$HOME/.horizon}/machines.json` when Horizon MCP is not
  connected), and remove `"$KEY_PATH"`, `"$KEY_PATH.pub"`, and `"$KNOWN_HOSTS"`.

## Safety and limits

- Never create resources without `horizon-managed=true` and
  `horizon-machine=<name>` (or the documented RunPod name/env tags).
- Never touch or delete unlabelled resources owned by the person's account.
- Never copy local `~/.ssh` private keys, `~/.aws`, `~/.config/gcloud`,
  `~/.azure`, `.env` files, cookies, or keyrings onto a rented machine.
- On quota or capacity errors (`QuotaExceeded`, `VcpuLimitExceeded`,
  `InsufficientInstanceCapacity`, `ZONE_RESOURCE_POOL_EXHAUSTED`,
  `SkuNotAvailable`), report the exact error and stop; do not retry in a loop or
  silently switch regions.
- Never guess prices. Show only prices returned by the CLI in the current run,
  or state that the CLI did not report a price.

## References

| Reference | Contents |
|---|---|
| [hetzner](references/hetzner.md) | `hcloud` preconditions, regions/types, firewall + server create, stop/start, delete proof, and traps |
| [aws](references/aws.md) | `aws ec2` dry-run permission preflight, default VPC create, stop/start, delete proof, and traps |
| [gcp](references/gcp.md) | `gcloud compute` preconditions, zone/type selection, firewall + instance create, delete proof, and traps |
| [azure](references/azure.md) | `az` subscription checks, Ubuntu 24.04 URN, resource-group create, deallocate, delete proof, and traps |
| [runpod](references/runpod.md) | `runpodctl` pod/template workflow, per-pod SSH key injection, remapped SSH port, delete proof, and traps |
| [tailscale](references/tailscale.md) | Joining a rented machine to Tailscale via OAuth `auth_keys` over stdin without leaking secrets |

Files in this skill

  • SKILL.md19.8 KB
  • references/aws.md7.3 KB
  • references/azure.md7 KB
  • references/gcp.md6.1 KB
  • references/hetzner.md6.3 KB
  • references/runpod.md5.9 KB
  • references/tailscale.md7.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.