# CLI commands

> Every flockvm CLI command with its options and real output: login, the catalog, VMs, SSH keys, environments, variables, secret files and MCP setup.

- URL: https://flockvm.com/docs/cli/commands
- Section: CLI
- Last updated: 2026-11-10

Every command takes `--json` (the API's JSON on standard output), `--api-url <url>` and `--help`. VMs and environments are named by id or by name. Install and log in first: see [Overview](https://flockvm.com/docs/cli/overview).

```text
flockvm login [--with-token] | logout | whoami
flockvm regions | sizes | images

flockvm vm list                                   (also: flockvm ls)
flockvm vm get <vm>
flockvm vm create <name> [--size <size>] [--region <id>] [--image <id>]
                         [--ssh-key <id|name|file.pub>] [--save-key]
                         [--env <environment|none>] [-e KEY=VALUE]... [--wait] [--timeout <s>]
flockvm vm start|stop|pause|resume <vm> [--wait] [--timeout <s>]
flockvm vm delete <vm> [--yes]
flockvm vm logs <vm> [--tail <n>]
flockvm vm ssh <vm> [-- <ssh options> <remote command>]

flockvm ssh-key list | add <file.pub|-> [--name <name>] | rm <id|name>

flockvm env list
flockvm env get [<env>]
flockvm env create <name> | rename <env> <new-name> | default <env> | delete <env> [--yes]
flockvm env update [<env>] [--secrets on|off] [--agent-credentials on|off] [--github-repos on|off]
                   [--members-can-use on|off] [--safe-for-third-parties on|off]
flockvm env set KEY=VALUE... [--env <env>] [--from-dotenv <file>]
flockvm env unset KEY... [--env <env>]
flockvm env file add <path in VM> <local file|-> [--env <env>]
flockvm env file rm <path in VM> [--env <env>]
flockvm env reveal [<env>] [--file <path in VM>]

flockvm mcp add <claude|cursor|codex|json> [--key-from-env | --embed-key] [--scope local|project|user]
                [--print] [--name <name>]
flockvm help [<command>] | --version
```

In the examples below, `HOST` stands for the host in your VM's SSH command, as in [Connect over SSH](https://flockvm.com/docs/vms/ssh).

## Account

### login

Saves an API key to the config file, after checking it with the API. Without options it offers to open **Settings → API keys** in your browser, then reads the key without echoing it. `--with-token` reads it from standard input; typed at a terminal rather than piped, it is hidden too.

```bash
flockvm login
flockvm login --with-token < key.txt
```

### logout

Removes the saved key from the config file. The key stays valid until you revoke it in [Settings → API keys](https://flockvm.com/dashboard/settings/api-keys).

### whoami

The user, organization and role the key acts as, the key's name and expiry, and where the key and the API URL come from. See [Log in](https://flockvm.com/docs/cli/overview#log-in).

## Catalog

What your organization can create VMs with.

```bash
flockvm regions
flockvm sizes
flockvm images
```

```text
ID   NAME        COUNTRY  ZONE  ENVIRONMENTS  SIZES AVAILABLE NOW
gra  France      France   EU    yes           small, default, large

NAME     VCPU  MEMORY  DISK    PRICE
small    2     4 GB    50 GB   $0.016/h
default  4     8 GB    50 GB   $0.032/h
large    8     16 GB   110 GB  $0.064/h
xlarge   16    32 GB   250 GB  $0.18/h

ID                  LABEL    SSH USER  DEFAULT  DESCRIPTION
ubuntu-26.04-agent  Agent    user      yes      Ubuntu 26.04 with Node, Python, Go, Rust, Java, Docker, Playwright browsers, Claude Code, Codex, Gemini, OpenCode, Cursor
ubuntu-26.04        Minimal  root               Ubuntu 26.04 with Node.js 22, Python, Docker and git
```

**SIZES AVAILABLE NOW** is what the region's host has room for at this moment. See [Sizes](https://flockvm.com/docs/vms/sizes), [Images](https://flockvm.com/docs/vms/images) and [Regions](https://flockvm.com/docs/vms/regions).

## VMs

### vm list

Every VM of the organization, newest first. `flockvm ls` is the same.

```text
ID         NAME     STATUS    SIZE     REGION  ENVIRONMENT  CREATED
vm_2kffke  agent-1  starting  small    gra                  now
vm_ceau36  web-1    running   default  gra     base         now
```

GitHub Actions runner VMs are listed with `(runner)` after their name. flockvm drives them: start, stop, pause, resume and delete refuse them.

### vm get

One VM, with its SSH command and its cost so far.

```bash
flockvm vm get web-1
```

```text
ID           vm_ceau36
Name         web-1
Status       running
Size         default (4 vCPU, 8 GB RAM, 50 GB disk)
Region       gra
Image        ubuntu-26.04-agent
Environment  base (v1)
Private IP   172.16.0.4
SSH          ssh -p 22003 user@HOST
Created      2026-11-01 06:20 UTC
Started      2026-11-01 06:20 UTC
Cost         $0.000 so far, $0.032/h while running
```

### vm create

Creates a VM and starts it. Only the name is required:

```bash
flockvm vm create web-1 --wait
```

```text
Size: default (4 vCPU, 8 GB, $0.032/h); --size to choose (flockvm sizes).
SSH key: your saved key laptop (SHA256:AotEVVP5PfwpdPptXhS/PFiBUOhM3ybakfPXQhkTxVQ); --ssh-key to choose.
Waiting for web-1 (starting)…
Created VM web-1 (vm_ceau36) in gra: running, environment base v1.
SSH: ssh -p 22003 user@HOST   (or: flockvm vm ssh web-1)
```

| Option                | Left out                                                                                                                                                                                  |
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--size <size>`       | The size the dashboard preselects: `default`, else `small`, `large`, `xlarge`, among those the region has room for.                                                                       |
| `--region <id>`       | The API's default region, France (`gra`), the one region today. `--region par` no longer exists.                                                                                          |
| `--image <id>`        | The Agent image, `ubuntu-26.04-agent`. `--image ubuntu-26.04` for Minimal. The Ubuntu 24.04 ids (`ubuntu-24.04-agent`, `ubuntu-24.04`) are refused with a `400` naming their replacement. |
| `--ssh-key <key>`     | The first key saved in your account, else `~/.ssh/id_ed25519.pub`. Give a saved key's id or name, or a `.pub` file. With a file, `--save-key` also saves it to your account.              |
| `--env <environment>` | The organization's default environment. `--env none` for no environment.                                                                                                                  |
| `-e KEY=VALUE`        | No per-VM variables. Repeat it for several; they go over the environment's.                                                                                                               |
| `--wait`              | Return at once, while the VM is `starting`. With `--wait`, return once it is out of `starting`, and exit `1` if it failed. `--timeout` caps the wait, 300 seconds by default.             |

```bash
flockvm vm create agent-1 --size small --env none -e DEBUG=1
flockvm vm create ci-box --image ubuntu-26.04 --ssh-key ~/.ssh/ci.pub --save-key --wait
```

The [create rules](https://flockvm.com/docs/vms/create) are the dashboard's: billing must be in order, a member can only use environments open to members, and environments and per-VM variables work in every region. When the region has no room for the size, the API answers `409 capacity`: try a smaller size, or look at `flockvm regions`.

### vm start, stop, pause, resume

```bash
flockvm vm pause web-1 --wait
flockvm vm resume web-1
flockvm vm stop agent-1 --wait
flockvm vm start agent-1 --wait
```

```text
Waiting for web-1 (pausing)…
web-1 (vm_ceau36): paused.
web-1 (vm_ceau36): starting.
```

**Pause** keeps memory and processes, **stop** keeps the disk only; neither is billed. See [Lifecycle](https://flockvm.com/docs/vms/lifecycle). Each one answers the VM's status right after the request; `--wait` waits until it is out of `starting`, `pausing` or `stopping`.

### vm delete

Deletes the VM and its disk. On a terminal it asks first; in a script, add `--yes`, or it exits with code `2` and deletes nothing.

```bash
flockvm vm delete agent-1 --yes
```

```text
Deleted VM agent-1 (vm_2kffke).
```

### vm logs

The VM's console log, oldest first. `--tail` (or `-n`) keeps the last lines, 1 to 1000.

```bash
flockvm vm logs web-1 -n 50
```

Use it when a VM is stuck starting or ended in error. For what happens inside a running VM, SSH in. See [Logs and live usage](https://flockvm.com/docs/vms/monitoring).

### vm ssh

Runs `ssh -p <port> user@host` with the VM's SSH address, the host, port and user the API gives. What follows `--` goes to `ssh`: options before the host, a remote command after it. The exit code is `ssh`'s.

```bash
flockvm vm ssh web-1
flockvm vm ssh web-1 -- uname -a
flockvm vm ssh web-1 -- -L 3000:localhost:3000
flockvm vm ssh web-1 -- -i ~/.ssh/ci_ed25519 'cd repo && git status'
```

Only your options reach `ssh`: the CLI builds the command from the host, port and user alone, and passes on no option of the API's `ssh.command` text. A paused VM must be resumed first, a stopped one started: the command says so instead of connecting. For `~/.ssh/config`, `scp` and port forwarding without the CLI, see [Connect over SSH](https://flockvm.com/docs/vms/ssh).

## SSH keys

The public keys saved in your account, the same list as **Settings → Account → SSH keys**. They belong to your user, not to the organization.

```bash
flockvm ssh-key add ~/.ssh/id_ed25519.pub --name laptop
flockvm ssh-key list
flockvm ssh-key rm laptop
```

```text
Saved SSH key laptop (key_w6ng9k8ekw3z, SHA256:AotEVVP5PfwpdPptXhS/PFiBUOhM3ybakfPXQhkTxVQ).

ID                NAME    TYPE         FINGERPRINT                                         LAST USED  ADDED
key_w6ng9k8ekw3z  laptop  ssh-ed25519  SHA256:AotEVVP5PfwpdPptXhS/PFiBUOhM3ybakfPXQhkTxVQ  never      now
```

`--name` defaults to the key's comment. `ssh-key add -` reads the key from standard input. A private key is refused. When several of your keys share a name, `rm` and `vm create --ssh-key` refuse that name and list the ids to use instead. Removing a key leaves the VMs that have it alone. See [SSH keys](https://flockvm.com/docs/vms/ssh-keys).

## Environments

[Environments](https://flockvm.com/docs/vms/environments) hold the variables and secret files every new VM gets. Everyone can read them; only owners and admins change them. Values are never printed, except by `env reveal`. A command without an environment uses the organization's default one.

### env list

```text
NAME     DEFAULT  VERSION  VARS  FILES  MEMBERS  ID
base     yes      1        0     0      yes      env_r8h54pmu
staging           6        4     1      yes      env_intjph4v
```

**MEMBERS** says whether members can create VMs with it.

### env get

Switches, variables with the last 4 characters of their value, and files with their size.

```bash
flockvm env get staging
```

```text
ID                    env_intjph4v
Name                  staging
Version               6
Secrets               on
Agent credentials     on
GitHub repos          on
Members can use       on
Safe for 3rd parties  off
Updated               2026-11-01 06:20 UTC

VARIABLE           VALUE  UPDATED
ANTHROPIC_API_KEY  …xyz9  now
DATABASE_URL       …/app  now
STRIPE_KEY         …4242  now

FILE (in ~)  SIZE  UPDATED
app/.env     95 B  now
```

### env create, rename, default, delete

```bash
flockvm env create staging
flockvm env rename staging stage
flockvm env default stage
flockvm env delete old-env --yes
```

Names are 1 to 40 characters among lowercase letters, digits and dashes. `none` is reserved: it means no environment. The default environment cannot be deleted: make another one the default first. `env delete` asks for confirmation on a terminal, and needs `--yes` elsewhere.

### env update

Turns an environment's switches on or off, then shows it.

```bash
flockvm env update staging --members-can-use off --agent-credentials on
```

| Option                             | Switch in the dashboard                                                          |
| ---------------------------------- | -------------------------------------------------------------------------------- |
| `--secrets on\|off`                | **Secrets**: the variables and files go into new VMs.                            |
| `--agent-credentials on\|off`      | **Agent credentials**: the organization's Anthropic key, as `ANTHROPIC_API_KEY`. |
| `--github-repos on\|off`           | **GitHub repositories**: the organization's repositories are cloned.             |
| `--members-can-use on\|off`        | **Members can use it**.                                                          |
| `--safe-for-third-parties on\|off` | **Safe for third parties**: nothing of the organization goes in.                 |

### env set

Sets variables. `KEY=-` reads that value from standard input, so it never lands in your shell history: piped as is, or typed at a terminal without echo (`STRIPE_KEY (hidden):`), one line only: pipe multi-line values such as a PEM key. `--from-dotenv` reads every variable of a `.env` file.

```bash
flockvm env set STRIPE_KEY=sk_test_4242 LOG_LEVEL=debug --env staging
pbpaste | flockvm env set OPENAI_API_KEY=- --env staging
```

```bash
flockvm env set --from-dotenv .env.staging --env staging
```

```text
Set DATABASE_URL (…/app), STRIPE_KEY (…4242), DEBUG (…) in staging, now version 4.
```

A value under 8 characters shows no last characters (`DEBUG (…)`). `--from-dotenv` reads `KEY=value` lines, skips comments, and accepts `export` and quoted values.

Each variable is saved by its own request, so setting three variables makes three new versions. VMs keep the version they were created with: only new VMs get the change.

### env unset

```bash
flockvm env unset DEBUG LOG_LEVEL --env staging
```

### env file

Adds or removes a secret file, written into each new VM at that path under the login user's home.

```bash
flockvm env file add app/.env ./.env.staging --env staging
op read "op://Engineering/staging/env" | flockvm env file add app/.env - --env staging
flockvm env file rm app/.env --env staging
```

```text
Added ~/app/.env to staging, now version 6.
```

`-` reads the file from standard input, which must be a pipe or a redirect, not a terminal. The CLI checks the limits before it uploads anything: 256 KiB a file, 20 files and 512 KiB in all per environment. More in [Environments](https://flockvm.com/docs/vms/environments).

### env reveal

Prints the values, for owners and admins only, and records the reveal in the [audit log](https://flockvm.com/docs/team/audit-log). Standard output is the variables as a valid `.env`, nothing else:

```bash
flockvm env reveal staging > staging.env
```

```text
ANTHROPIC_API_KEY=sk-ant-xyz9
DATABASE_URL=postgres://app@db.internal/app
STRIPE_KEY=sk_test_4242
```

The header line (`# staging v6: secret values below.`) and the list of files (`# Files, not printed: ~/app/.env (95 B). Print one with --file <path>.`) go to standard error. `--file` prints one file's content instead, byte for byte, binary files included:

```bash
flockvm env reveal staging --file app/.env > app.env
```

`--json` gives everything at once: the variables, and each file in `content_base64`.

## MCP

### mcp add

Connects an MCP client to the [flockvm MCP server](https://flockvm.com/docs/mcp).

```bash
flockvm mcp add claude
flockvm mcp add claude --scope user --print
flockvm mcp add claude --scope project --key-from-env
flockvm mcp add cursor
flockvm mcp add codex
flockvm mcp add json
```

`claude` runs `claude mcp add` for Claude Code (`--print` shows the command instead, `--scope` is passed on). At the `local` and `user` scopes, the header holds the key you are logged in with, in Claude Code's own private config. With `--key-from-env` it is the literal text `Bearer ${FLOCKVM_API_KEY}`, which Claude Code expands from its environment when it starts.

`--scope project` writes `.mcp.json` at the root of the repository, which is usually committed, so it requires `--key-from-env`; without it the command refuses and changes nothing. If `claude` is not installed, the command to run is printed with `<key>` in place of the key.

`cursor`, `codex` and `json` print the snippet for that client's config file. It reads the key from `FLOCKVM_API_KEY` in the client's environment, so it can be committed; `--embed-key` writes your key into it instead, for a private file only. Neither `--key-from-env` nor printing a snippet needs you to be logged in. `--name` changes the server's name in the client, `flockvm` by default. What each one prints, and how to do it by hand, is in [Connect a client](https://flockvm.com/docs/mcp/clients).
