# avr vm

Manage long-running VMs (SSH/RDP/VNC).

```sh
avr vm [OPTIONS] COMMAND [ARGS]...
```

## Subcommands

### `avr vm bootstrap`

Set up a RUNNING VM with your dev essentials over SSH.

```sh
avr vm bootstrap [OPTIONS] VM_ID_OR_NAME
```

```sh
Each selected step runs on the VM and streams its output; bootstrap stops at
the first failure. Secrets (GitHub token, forwarded env values, agent
credentials) ride SSH stdin, never argv. A forwarded CLAUDE_CODE_OAUTH_TOKEN
is a year-long, subscription-wide bearer, so it is only carried under the
explicit --forward-agent-creds opt-in. Bootstrap changes survive pause
and resume on the preserved disk. Example:
```

```sh
avr vm bootstrap cvm-abc123 --setup-github --install claude,codex \
  --repo https://github.com/me/project --env AWS_REGION=eu-north-1
```

**Arguments**

- <code class="cli-arg">VM_ID_OR_NAME</code>

**Options**

- <code class="cli-flag">&#x2D;&#x2D;org, -o</code> <code class="cli-value">&lt;TEXT&gt;</code> — Organization ID. Uses default org if not specified (see: avr config set org).
- <code class="cli-flag">-i, &#x2D;&#x2D;identity</code> <code class="cli-value">&lt;PATH&gt;</code> — SSH private key file. Sets IdentitiesOnly=yes, so ssh offers only this key and other configured identities, including matching keys in the agent.
- <code class="cli-flag">&#x2D;&#x2D;setup-github / &#x2D;&#x2D;no-setup-github</code> — Forward your local `gh auth token` into the VM (gh auth login --with-token + gh auth setup-git).
- <code class="cli-flag">&#x2D;&#x2D;install</code> <code class="cli-value">&lt;TEXT&gt;</code> — Install an agent CLI (repeatable or comma-separated): claude, codex. _(repeatable)_
- <code class="cli-flag">&#x2D;&#x2D;forward-agent-creds</code> — Forward the installed agents' credentials from your environment (ANTHROPIC_API_KEY / CLAUDE_CODE_OAUTH_TOKEN / OPENAI_API_KEY). If claude has none, offers to run `claude setup-token`.
- <code class="cli-flag">&#x2D;&#x2D;install-avr</code> — Install the native avr release matching this CLI in ~/.local/bin (requires curl, tar and SHA-256 tooling).
- <code class="cli-flag">&#x2D;&#x2D;repo, -R</code> <code class="cli-value">&lt;TEXT&gt;</code> — Clone this git repo into the VM's home directory.
- <code class="cli-flag">&#x2D;&#x2D;ref</code> <code class="cli-value">&lt;TEXT&gt;</code> — Branch, refs/pull/&lt;number&gt;/head or 40-character commit SHA to check out after cloning (requires --repo). A pull request or commit is checked out detached. Tags are not supported.
- <code class="cli-flag">&#x2D;&#x2D;dotfiles</code> <code class="cli-value">&lt;TEXT&gt;</code> — Clone this dotfiles repo and run its installer.
- <code class="cli-flag">&#x2D;&#x2D;env</code> <code class="cli-value">&lt;TEXT&gt;</code> — Set an env var in the VM: KEY=VALUE, or a bare KEY to forward it from your environment. Repeatable. _(repeatable)_
- <code class="cli-flag">&#x2D;&#x2D;run</code> <code class="cli-value">&lt;TEXT&gt;</code> — Run a custom script last: an inline script, or @path to a file.
- <code class="cli-flag">&#x2D;&#x2D;print</code> — Print the ordered plan (secrets redacted) without running.

### `avr vm capabilities`

List available operating systems, architectures, sizes, and quotas.

```sh
avr vm capabilities [OPTIONS]
```

**Options**

- <code class="cli-flag">&#x2D;&#x2D;org, -o</code> <code class="cli-value">&lt;TEXT&gt;</code> — Organization ID or slug.
- <code class="cli-flag">&#x2D;&#x2D;json</code> — Emit capabilities and quotas as JSON.

### `avr vm create`

Create a long-running VM.

```sh
avr vm create [OPTIONS]
```

```sh
Provisioning is asynchronous: poll `avr vm show <id>` until the state is
RUNNING and endpoints are populated, or pass --wait to block until then and
print a ready-to-paste connect command with the password baked in. The
response carries a one-time password for the VM's local account; save it
now, it is never stored.
```

```sh
With --from-spawn-script it creates an agent sandbox for a coding-agent
vendor's work order instead, for that vendor's controller to run. For
example, as Claude Code's spawn-runner hook:
    exec avr vm create --from-spawn-script claude-code --org <org-id>
```

Organization admins can pass --egress-rules inline or as @path to a JSON
file. Scoped tokens cannot set these rules. Use an array of up to 100
rule objects. Every rule requires action ("allow" or "deny"). A
non-default rule takes exactly one of fqdn (hostname) or cidr (IPv4 CIDR).
Protocol is "any" by default and also accepts "tcp", "udp" and "icmp".
TCP and UDP rules may set port_start and port_end to integers from 0 to
65535. One endpoint matches one port. Two form an inclusive range with
start at or below end. Omitting both matches all ports.

An optional is_default boolean defaults to false. At most one rule can
set it to true, with protocol "any" and no destination or ports. Agent
sandboxes always deny unmatched traffic. The first matching non-default
rule in array order wins. An optional nonnegative integer position is
ignored.

Save these HTTPS rules as meteor-egress.json.

```sh
cat > meteor-egress.json <<'JSON'
[
  {"action":"allow","fqdn":"install.meteor.com","protocol":"tcp","port_start":443},
  {"action":"allow","fqdn":"static.meteor.com","protocol":"tcp","port_start":443},
  {"action":"allow","fqdn":"packages.meteor.com","protocol":"tcp","port_start":443},
  {"action":"allow","fqdn":"warehouse.meteor.com","protocol":"tcp","port_start":443}
]
JSON
```

Apply the file when creating or updating a VM.

```sh
avr vm create --name meteor --os linux --size 2-vcpu --egress-rules @meteor-egress.json
avr vm update meteor --egress-rules @meteor-egress.json
```

**Options**

- <code class="cli-flag">&#x2D;&#x2D;org, -o</code> <code class="cli-value">&lt;TEXT&gt;</code> — Organization ID. Uses default org if not specified (see: avr config set org).
- <code class="cli-flag">&#x2D;&#x2D;name</code> <code class="cli-value">&lt;TEXT&gt;</code> — Unique VM name. Generated by the server when omitted.
- <code class="cli-flag">&#x2D;&#x2D;os</code> <code class="cli-value">&lt;CHOICE&gt;</code> — Guest operating system. Required unless --from-spawn-script, which is always linux. _(choices: `linux`, `macos`, `windows`)_
- <code class="cli-flag">&#x2D;&#x2D;arch</code> <code class="cli-value">&lt;TEXT&gt;</code> — CPU architecture (see: avr vm capabilities). Defaults to the selected OS's default.
- <code class="cli-flag">&#x2D;&#x2D;idempotency-key</code> <code class="cli-value">&lt;TEXT&gt;</code> — Retry creates safely with the same organization-scoped key.
- <code class="cli-flag">&#x2D;&#x2D;https-port</code> <code class="cli-value">&lt;INTEGER RANGE&gt;</code> — Publish a guest port as public HTTPS. Repeatable; the first is default. _(repeatable)_
- <code class="cli-flag">&#x2D;&#x2D;os-version</code> <code class="cli-value">&lt;TEXT&gt;</code> — Guest OS version (e.g. ubuntu-26.04; see: avr vm capabilities). Defaults to the latest version for the chosen --os.
- <code class="cli-flag">&#x2D;&#x2D;size</code> <code class="cli-value">&lt;TEXT&gt;</code> — Hardware tier, e.g. 2-vcpu (see: avr vm capabilities). Availability: linux x86_64 1-32 vCPU, linux arm64 up to 16, macos 8/16, windows 2-16. Required unless --from-spawn-script, which defaults to 4-vcpu.
- <code class="cli-flag">&#x2D;&#x2D;ssh-key</code> <code class="cli-value">&lt;TEXT&gt;</code> — SSH public key, or @path to read one from a file. Repeatable. _(repeatable)_
- <code class="cli-flag">&#x2D;&#x2D;remote-desktop / &#x2D;&#x2D;no-remote-desktop</code> — Enable a remote desktop: RDP (Windows, Linux) or VNC (macOS Screen Sharing). Availability depends on OS version; the server validates.
- <code class="cli-flag">&#x2D;&#x2D;ttl</code> <code class="cli-value">&lt;TEXT&gt;</code> — TTL before pause, or deletion when pause is unavailable (e.g. 8h, 7d, 1800s). Default 8h, max 7d.
- <code class="cli-flag">&#x2D;&#x2D;egress-rules</code> <code class="cli-value">&lt;TEXT&gt;</code> — Per-VM egress firewall rules as a JSON array, or @path to a JSON file.
- <code class="cli-flag">&#x2D;&#x2D;repo, -R</code> <code class="cli-value">&lt;TEXT&gt;</code> — Git repository (owner/repo) to preload into the VM at boot. Best-effort; the checkout is warmed from Avrea's mirror when available.
- <code class="cli-flag">&#x2D;&#x2D;ref</code> <code class="cli-value">&lt;TEXT&gt;</code> — Branch, refs/pull/&lt;number&gt;/head or 40-character commit SHA to preload (default: the repository's default branch). Requires --repo. Tags are not supported.
- <code class="cli-flag">&#x2D;&#x2D;fetch-depth</code> <code class="cli-value">&lt;INTEGER RANGE&gt;</code> — Git history to preload with --repo, like actions/checkout fetch-depth: 1 (default) = branch tip, N = N commits, 0 = all branches and tags.
- <code class="cli-flag">&#x2D;&#x2D;disable-cache</code> <code class="cli-value">&lt;TEXT&gt;</code> — Disable a build/CI cache on this VM (repeatable, or comma-separated). Narrowing only: a VM can turn off an inherited cache but not turn one on. e.g. gha, packages, bazel, gradle, maven, turbo, nx, go-build (or a raw cache.&lt;name&gt;.enabled key). Repository-scoped caches require --repo. _(repeatable)_
- <code class="cli-flag">&#x2D;&#x2D;wait</code> — Wait until the VM is RUNNING, then print a ready-to-paste connect command with the password baked in.
- <code class="cli-flag">&#x2D;&#x2D;wait-timeout</code> <code class="cli-value">&lt;INTEGER&gt;</code> — Seconds to wait when --wait is set. _(default: `300`)_
- <code class="cli-flag">&#x2D;&#x2D;json</code> — Emit the raw API response (VM plus one-time password) as JSON.
- <code class="cli-flag">&#x2D;&#x2D;from-spawn-script</code> <code class="cli-value">&lt;CHOICE&gt;</code> — Run as a coding-agent vendor controller's spawn script: read the work order the controller passes in its environment, create an agent sandbox that starts the vendor's worker, print its ID, and exit 0 when created or already created, 1 to have the vendor retry, 2 or higher when refused. Needs an organization ID (org-...) from --org or the default org. _(choices: `claude-code`)_

### `avr vm delete`

Delete a VM.

```sh
avr vm delete [OPTIONS] VM_ID_OR_NAME
```

Delete a VM. Asynchronous while live: shows DELETING until the node confirms the stop.

**Arguments**

- <code class="cli-arg">VM_ID_OR_NAME</code>

**Options**

- <code class="cli-flag">&#x2D;&#x2D;org, -o</code> <code class="cli-value">&lt;TEXT&gt;</code> — Organization ID. Uses default org if not specified (see: avr config set org).
- <code class="cli-flag">&#x2D;&#x2D;yes, -y</code> — Skip the confirmation prompt.
- <code class="cli-flag">&#x2D;&#x2D;wait</code> — Wait until the VM is fully deleted before returning.
- <code class="cli-flag">&#x2D;&#x2D;wait-timeout</code> <code class="cli-value">&lt;INTEGER&gt;</code> — Seconds to wait when --wait is set. _(default: `300`)_
- <code class="cli-flag">&#x2D;&#x2D;json</code> — Emit the raw API response as JSON.

### `avr vm firewall`

Watch firewall blocks on a running VM or agent sandbox.

```sh
avr vm firewall [OPTIONS] VM_ID_OR_NAME
```

Watch firewall blocks on a running VM or agent sandbox until its run ends. Pass the VM ID or display name. Each snapshot shows recent denied DNS names and cumulative packet and byte counts by IP firewall rule. Destination IPs of dropped packets are unavailable.

**Arguments**

- <code class="cli-arg">VM_ID_OR_NAME</code> — VM ID or display name.

**Options**

- <code class="cli-flag">&#x2D;&#x2D;org, -o</code> <code class="cli-value">&lt;TEXT&gt;</code> — Organization ID or slug.
- <code class="cli-flag">&#x2D;&#x2D;json</code> — Emit the full live snapshot, including top destinations, as one JSON object per line.

### `avr vm fork`

Boot a copy of a PAUSED VM's disk; the source remains paused.

```sh
avr vm fork [OPTIONS] VM_ID_OR_NAME
```

Copies the source's machine configuration and disk, including its SSH host
keys and password, but discards memory state. A scoped-token password may
be replaced without returning its replacement. No password is returned; use
update --rotate-password if needed. Requires admin access to the source.

**Arguments**

- <code class="cli-arg">VM_ID_OR_NAME</code>

**Options**

- <code class="cli-flag">&#x2D;&#x2D;name</code> <code class="cli-value">&lt;TEXT&gt;</code> — Fork name. Defaults to a name derived from the source.
- <code class="cli-flag">&#x2D;&#x2D;ttl</code> <code class="cli-value">&lt;TEXT&gt;</code> — Fork TTL (e.g. 8h, 7d). Default 8h, max 7d.
- <code class="cli-flag">&#x2D;&#x2D;org, -o</code> <code class="cli-value">&lt;TEXT&gt;</code> — Organization ID or slug.
- <code class="cli-flag">&#x2D;&#x2D;wait</code> — Wait for the fork to become connectable.
- <code class="cli-flag">&#x2D;&#x2D;wait-timeout</code> <code class="cli-value">&lt;INTEGER RANGE&gt;</code> — Seconds to wait when --wait is set. _(default: `300`)_
- <code class="cli-flag">&#x2D;&#x2D;json</code> — Emit the fork VM as JSON.

### `avr vm list`

List the organization's VMs, newest first (deleted ones excluded).

```sh
avr vm list [OPTIONS]
```

**Options**

- <code class="cli-flag">&#x2D;&#x2D;org, -o</code> <code class="cli-value">&lt;TEXT&gt;</code> — Organization ID. Uses default org if not specified (see: avr config set org).
- <code class="cli-flag">&#x2D;&#x2D;state</code> <code class="cli-value">&lt;CHOICE&gt;</code> — Filter by lifecycle state. _(choices: `PENDING`, `STARTING`, `RUNNING`, `PAUSING`, `PAUSED`, `STOPPING`, `DELETING`, `FAILED`)_
- <code class="cli-flag">&#x2D;&#x2D;scope</code> <code class="cli-value">&lt;CHOICE&gt;</code> — Visible VMs or only your own. _(choices: `all`, `mine` · default: `all`)_
- <code class="cli-flag">&#x2D;&#x2D;sandbox / &#x2D;&#x2D;no-sandbox</code> — Agent sandboxes only, or human-created VMs only.
- <code class="cli-flag">-L, &#x2D;&#x2D;limit</code> <code class="cli-value">&lt;INTEGER RANGE&gt;</code> — Max VMs to return. _(default: `50`)_
- <code class="cli-flag">&#x2D;&#x2D;cursor</code> <code class="cli-value">&lt;TEXT&gt;</code> — Pagination cursor from a previous response.
- <code class="cli-flag">&#x2D;&#x2D;json</code> — Emit the VM list as JSON.

### `avr vm metrics`

Show CPU/memory/IO metrics for a VM's current or last run.

```sh
avr vm metrics [OPTIONS] VM_ID_OR_NAME
```

**Arguments**

- <code class="cli-arg">VM_ID_OR_NAME</code>

**Options**

- <code class="cli-flag">&#x2D;&#x2D;org, -o</code> <code class="cli-value">&lt;TEXT&gt;</code> — Organization ID or slug.
- <code class="cli-flag">&#x2D;&#x2D;source</code> <code class="cli-value">&lt;CHOICE&gt;</code> — Metric source. Repeatable; defaults to cpu and memory. _(choices: `cpu`, `memory`, `filesystem`, `load`, `disk-io`, `disk-ops`, `network` · repeatable)_
- <code class="cli-flag">&#x2D;&#x2D;start</code> <code class="cli-value">&lt;INTEGER&gt;</code> — Start time in Unix seconds (single-shot only).
- <code class="cli-flag">&#x2D;&#x2D;end</code> <code class="cli-value">&lt;INTEGER&gt;</code> — End time in Unix seconds (single-shot only).
- <code class="cli-flag">&#x2D;&#x2D;watch, -w</code> — Stream live metrics until the run completes; Ctrl-C to exit.
- <code class="cli-flag">&#x2D;&#x2D;json</code> — Emit metrics JSON; watch emits one snapshot per line.

### `avr vm pause`

Pause a RUNNING Linux x86_64 VM while preserving its disk.

```sh
avr vm pause [OPTIONS] VM_ID_OR_NAME
```

By default the snapshot is disk-only: the filesystem survives, but resume
performs a fresh boot and running processes do not. Pass --memory to also
preserve guest memory and continue processes from where they stopped.

**Arguments**

- <code class="cli-arg">VM_ID_OR_NAME</code>

**Options**

- <code class="cli-flag">&#x2D;&#x2D;org, -o</code> <code class="cli-value">&lt;TEXT&gt;</code> — Organization ID. Uses default org if not specified (see: avr config set org).
- <code class="cli-flag">&#x2D;&#x2D;memory</code> — Include guest memory and device state so running processes continue on resume.
- <code class="cli-flag">&#x2D;&#x2D;wait</code> — Wait until the VM reaches PAUSED before returning.
- <code class="cli-flag">&#x2D;&#x2D;wait-timeout</code> <code class="cli-value">&lt;INTEGER&gt;</code> — Seconds to wait when --wait is set. _(default: `300`)_
- <code class="cli-flag">&#x2D;&#x2D;json</code> — Emit the raw API response as JSON.

### `avr vm port-forward`

Forward one or more local ports to TCP ports on the VM over SSH.

```sh
avr vm port-forward [OPTIONS] VM_ID_OR_NAME
```

The generic primitive behind `avr vm rdp` / `avr vm vnc`: opens
127.0.0.1:&lt;local&gt; -&gt; &lt;VM&gt;:&lt;guest&gt; through the VM's SSH endpoint for each
--port, and holds them open until Ctrl-C. Bring your own client.

```sh
avr vm port-forward cvm-abc123 --port 8080
avr vm port-forward cvm-abc123 --port 8080 --port 5432 --port 9000:3000
```

**Arguments**

- <code class="cli-arg">VM_ID_OR_NAME</code>

**Options**

- <code class="cli-flag">&#x2D;&#x2D;org, -o</code> <code class="cli-value">&lt;TEXT&gt;</code> — Organization ID. Uses default org if not specified (see: avr config set org).
- <code class="cli-flag">&#x2D;&#x2D;port</code> <code class="cli-value">&lt;TEXT&gt;</code> — Guest TCP port to forward, optionally with a local bind port (e.g. 8080 or 9000:8080). Repeatable. _(repeatable · required)_
- <code class="cli-flag">&#x2D;&#x2D;local-port</code> <code class="cli-value">&lt;INTEGER RANGE&gt;</code> — Local port to bind for a single bare --port (with multiple ports, use --port LOCAL:GUEST instead).
- <code class="cli-flag">-i, &#x2D;&#x2D;identity</code> <code class="cli-value">&lt;PATH&gt;</code> — SSH private key file. Sets IdentitiesOnly=yes, so ssh offers only this key and other configured identities, including matching keys in the agent.
- <code class="cli-flag">&#x2D;&#x2D;print</code> — Print the ssh command and exit, without opening the tunnel.

### `avr vm rdp`

Open an RDP desktop on a Windows or Linux VM over an SSH tunnel.

```sh
avr vm rdp [OPTIONS] VM_ID_OR_NAME
```

Forwards a local port to the guest's RDP service (:3389) through the VM's
SSH endpoint, so the desktop is never exposed publicly. Holds the tunnel
open until Ctrl-C; pass --launch to also start a local RDP client.

**Arguments**

- <code class="cli-arg">VM_ID_OR_NAME</code>

**Options**

- <code class="cli-flag">&#x2D;&#x2D;org, -o</code> <code class="cli-value">&lt;TEXT&gt;</code> — Organization ID. Uses default org if not specified (see: avr config set org).
- <code class="cli-flag">&#x2D;&#x2D;local-port</code> <code class="cli-value">&lt;INTEGER RANGE&gt;</code> — Local port to bind (default: an unused port).
- <code class="cli-flag">-i, &#x2D;&#x2D;identity</code> <code class="cli-value">&lt;PATH&gt;</code> — SSH private key file. Sets IdentitiesOnly=yes, so ssh offers only this key and other configured identities, including matching keys in the agent.
- <code class="cli-flag">&#x2D;&#x2D;launch / &#x2D;&#x2D;no-launch</code> — Also start a local RDP client, instead of just printing the connect command.
- <code class="cli-flag">&#x2D;&#x2D;print</code> — Print the tunnel and client commands and exit, without opening the tunnel.

### `avr vm resume`

Resume a PAUSED VM from its preserved snapshot.

```sh
avr vm resume [OPTIONS] VM_ID_OR_NAME
```

The existing password remains unless resume withdraws credentials supplied
to a scoped token. Use update --rotate-password to obtain a fresh one.
If a memory restore cannot complete,
retry with --discard-memory to boot the preserved disk without restoring
running processes.

**Arguments**

- <code class="cli-arg">VM_ID_OR_NAME</code>

**Options**

- <code class="cli-flag">&#x2D;&#x2D;org, -o</code> <code class="cli-value">&lt;TEXT&gt;</code> — Organization ID. Uses default org if not specified (see: avr config set org).
- <code class="cli-flag">&#x2D;&#x2D;discard-memory</code> — Ignore saved memory state and fresh-boot the preserved disk (recovery for a stuck memory restore).
- <code class="cli-flag">&#x2D;&#x2D;wait</code> — Wait until the VM is RUNNING and connectable.
- <code class="cli-flag">&#x2D;&#x2D;wait-timeout</code> <code class="cli-value">&lt;INTEGER&gt;</code> — Seconds to wait when --wait is set. _(default: `300`)_
- <code class="cli-flag">&#x2D;&#x2D;json</code> — Emit the raw API response as JSON.

### `avr vm rotate-https-label`

Replace public HTTPS URLs to invalidate leaked URLs.

```sh
avr vm rotate-https-label [OPTIONS] VM_ID_OR_NAME
```

Routes change once ingress applies the rotation. On a running VM,
AVREA_SANDBOX_URL (in new login shells) and /vm/info follow within seconds;
a paused VM picks up the new URLs at resume.

**Arguments**

- <code class="cli-arg">VM_ID_OR_NAME</code>

**Options**

- <code class="cli-flag">&#x2D;&#x2D;org, -o</code> <code class="cli-value">&lt;TEXT&gt;</code> — Organization ID or slug.
- <code class="cli-flag">&#x2D;&#x2D;json</code> — Emit the updated VM as JSON.

### `avr vm show`

Show a VM's details, including connection endpoints and egress rules.

```sh
avr vm show [OPTIONS] VM_ID_OR_NAME
```

**Arguments**

- <code class="cli-arg">VM_ID_OR_NAME</code>

**Options**

- <code class="cli-flag">&#x2D;&#x2D;org, -o</code> <code class="cli-value">&lt;TEXT&gt;</code> — Organization ID. Uses default org if not specified (see: avr config set org).
- <code class="cli-flag">&#x2D;&#x2D;json</code> — Emit the full VM record (with egress rules) as JSON.

### `avr vm ssh`

Open an SSH session to a RUNNING VM, or run a command on it.

```sh
avr vm ssh [OPTIONS] VM_ID_OR_NAME [SSH_ARGS]...
```

With no extra arguments this opens an interactive session. Anything after
`--` is run as a remote command instead, e.g.:

    avr vm ssh cvm-abc123 -- uname -a

A one-off `-- <cmd>` runs in a non-login shell that sources no startup files,
so it won't see env forwarded by `avr vm bootstrap`. Pass `--login` to run it
in a login shell instead (e.g. so `claude` finds its subscription token):

    avr vm ssh cvm-abc123 --login -- claude -p 'summarize the repo'

Pass `--session <name>` to attach to (or create) a persistent tmux session,
so the shell and any long-running process in it survive a dropped
connection; reconnect with the same name to resume where you left off. A
`-- <cmd>` given with --session runs only when the session is first created;
reattaching to an existing session resumes it and does not rerun the command.

When the VM's endpoint publishes a host key it is pinned, so the first
connect neither prompts nor is spoofable. If the endpoint has no host key,
`avr` prints a warning and falls back to trust-on-first-use, so this
spoofing protection is conditional rather than guaranteed. For
port-forwarding use `avr vm port-forward`.

**Arguments**

- <code class="cli-arg">VM_ID_OR_NAME</code>
- <code class="cli-arg">[SSH_ARGS...]</code>

**Options**

- <code class="cli-flag">&#x2D;&#x2D;org</code> <code class="cli-value">&lt;TEXT&gt;</code> — Organization ID. Uses default org if not specified (see: avr config set org).
- <code class="cli-flag">-i, &#x2D;&#x2D;identity</code> <code class="cli-value">&lt;PATH&gt;</code> — SSH private key file. Sets IdentitiesOnly=yes, so ssh offers only this key and other configured identities, including matching keys in the agent.
- <code class="cli-flag">&#x2D;&#x2D;session</code> <code class="cli-value">&lt;TEXT&gt;</code> — Attach to (or create) a persistent tmux session by this name, so the shell and any long-running process in it survive a dropped connection. Reconnect with the same --session. A `-- <cmd>` runs only when the session is created, not on reattach.
- <code class="cli-flag">&#x2D;&#x2D;login</code> — Run the `-- <cmd>` in a login shell (bash -lc) so it sees bootstrap-forwarded env like CLAUDE_CODE_OAUTH_TOKEN. Needed for a non-interactive command; a plain `ssh host cmd` shell sources nothing.
- <code class="cli-flag">&#x2D;&#x2D;print</code> — Print the ssh command instead of running it.

### `avr vm ssh-config`

Print (or --append) an ssh_config Host block for a RUNNING VM.

```sh
avr vm ssh-config [OPTIONS] VM_ID_OR_NAME
```

Reach the VM with plain `ssh`, scp/rsync, and VS Code / Cursor Remote-SSH,
host key pinned, without wrapping each tool. Redirect it yourself:

    avr vm ssh-config cvm-abc123 >> ~/.ssh/config

or let --append manage the block for you (idempotent — re-run after a
resume to refresh the endpoint in place):

    avr vm ssh-config cvm-abc123 --append

The block references a dedicated known_hosts file that this command writes
the pinned host key into (one entry per VM). If the endpoint publishes no
host key, the block falls back to accept-new (trust-on-first-use) and a
warning is printed.

**Arguments**

- <code class="cli-arg">VM_ID_OR_NAME</code>

**Options**

- <code class="cli-flag">&#x2D;&#x2D;org, -o</code> <code class="cli-value">&lt;TEXT&gt;</code> — Organization ID. Uses default org if not specified (see: avr config set org).
- <code class="cli-flag">-i, &#x2D;&#x2D;identity</code> <code class="cli-value">&lt;PATH&gt;</code> — IdentityFile to write into the block, with IdentitiesOnly yes.
- <code class="cli-flag">&#x2D;&#x2D;host-alias</code> <code class="cli-value">&lt;TEXT&gt;</code> — Host alias for the block (default: avr-&lt;vm-id&gt;).
- <code class="cli-flag">&#x2D;&#x2D;known-hosts-file</code> <code class="cli-value">&lt;PATH&gt;</code> — Where to pin the host key (default: ~/.ssh/avr_known_hosts).
- <code class="cli-flag">&#x2D;&#x2D;append</code> — Write the block into your SSH config (default: ~/.ssh/config) instead of printing it, replacing any prior block for the same alias in place.
- <code class="cli-flag">&#x2D;&#x2D;config-file</code> <code class="cli-value">&lt;PATH&gt;</code> — SSH config file for --append (default: ~/.ssh/config).

### `avr vm update`

Update a VM's name, TTL, or SSH keys, or rotate its password.

```sh
avr vm update [OPTIONS] VM_ID_OR_NAME
```

Use avr vm pause, avr vm resume, or avr vm delete for lifecycle changes.

--egress-rules replaces the entire VM rule list. Pass [] to clear it.
See avr vm create --help for the JSON format and an example.

**Arguments**

- <code class="cli-arg">VM_ID_OR_NAME</code>

**Options**

- <code class="cli-flag">&#x2D;&#x2D;org, -o</code> <code class="cli-value">&lt;TEXT&gt;</code> — Organization ID. Uses default org if not specified (see: avr config set org).
- <code class="cli-flag">&#x2D;&#x2D;name</code> <code class="cli-value">&lt;TEXT&gt;</code> — New display name.
- <code class="cli-flag">&#x2D;&#x2D;ttl</code> <code class="cli-value">&lt;TEXT&gt;</code> — Extend the TTL window from now (e.g. 8h, 7d). Max 7d.
- <code class="cli-flag">&#x2D;&#x2D;ssh-key</code> <code class="cli-value">&lt;TEXT&gt;</code> — Replace stored SSH public keys (literal or @path). Repeatable. Applies live on a RUNNING VM, otherwise at next resume. _(repeatable)_
- <code class="cli-flag">&#x2D;&#x2D;rotate-password</code> — Provision a fresh one-time password (returned in the response).
- <code class="cli-flag">&#x2D;&#x2D;egress-rules</code> <code class="cli-value">&lt;TEXT&gt;</code> — Replace the per-VM egress rules with this JSON array (or @path to a file).
- <code class="cli-flag">&#x2D;&#x2D;json</code> — Emit the raw API response as JSON.
- <code class="cli-flag">&#x2D;&#x2D;https-port</code> <code class="cli-value">&lt;INTEGER RANGE&gt;</code> — Replace public HTTPS ports. Repeatable; applies live on a RUNNING VM, otherwise at next start or resume. _(repeatable)_
- <code class="cli-flag">&#x2D;&#x2D;clear-https-ports</code> — Publish no HTTPS ports. Applies live on a RUNNING VM, otherwise at next start or resume.

### `avr vm usage`

Show usage metering (runtime / vCPU / memory seconds) per VM.

```sh
avr vm usage [OPTIONS]
```

Each power-on cycle's window is clipped to the requested period and summed.
Deleted VMs are included: usage survives deletion.

**Options**

- <code class="cli-flag">&#x2D;&#x2D;org, -o</code> <code class="cli-value">&lt;TEXT&gt;</code> — Organization ID. Uses default org if not specified (see: avr config set org).
- <code class="cli-flag">&#x2D;&#x2D;start</code> <code class="cli-value">&lt;DATETIME&gt;</code> — Inclusive period start (default: 30 days ago).
- <code class="cli-flag">&#x2D;&#x2D;end</code> <code class="cli-value">&lt;DATETIME&gt;</code> — Exclusive period end (default: now).
- <code class="cli-flag">&#x2D;&#x2D;json</code> — Emit the usage report as JSON.

### `avr vm vnc`

Open a VNC desktop on a macOS VM (Screen Sharing) over an SSH tunnel.

```sh
avr vm vnc [OPTIONS] VM_ID_OR_NAME
```

Forwards a local port to the guest's Screen Sharing service (:5900) through
the VM's SSH endpoint, so the desktop is never exposed publicly. Holds the
tunnel open until Ctrl-C; pass --launch to also open Screen Sharing.

**Arguments**

- <code class="cli-arg">VM_ID_OR_NAME</code>

**Options**

- <code class="cli-flag">&#x2D;&#x2D;org, -o</code> <code class="cli-value">&lt;TEXT&gt;</code> — Organization ID. Uses default org if not specified (see: avr config set org).
- <code class="cli-flag">&#x2D;&#x2D;local-port</code> <code class="cli-value">&lt;INTEGER RANGE&gt;</code> — Local port to bind (default: an unused port).
- <code class="cli-flag">-i, &#x2D;&#x2D;identity</code> <code class="cli-value">&lt;PATH&gt;</code> — SSH private key file. Sets IdentitiesOnly=yes, so ssh offers only this key and other configured identities, including matching keys in the agent.
- <code class="cli-flag">&#x2D;&#x2D;launch / &#x2D;&#x2D;no-launch</code> — Also start a local VNC client (macOS Screen Sharing), instead of just printing the connect command.
- <code class="cli-flag">&#x2D;&#x2D;print</code> — Print the tunnel and client commands and exit, without opening the tunnel.