vms
Create, connect to and manage your virtual machines
The vms commands manage your virtual machines. Machine IDs look like vm_abc123.
stashbase vms connect # your machine (or pick/create one), attached to its tmux session
stashbase vms cp ./notes.md :notes.md # copy a file to your machine
stashbase vms list # your machines and their state
stashbase vms usage # the workspace's machine time and traffic this periodManaging machines needs a personal API key with the Manage virtual machines permission. Creating one requires two-factor authentication.
connect
stashbase vms connect [ID] [--location us|eu|asia] [--forward [LOCAL:]PORT]... [--keep-awake[=DURATION]] [--no-tmux] [--ssh-arg <ARG>]... [-- <COMMAND>...]Connects to a machine, resuming or starting it first if it is suspended or stopped. Without an ID it uses your only machine; with several you pick one, and with none it creates one. It attaches to the machine's shared tmux session, the same one the dashboard terminal shows.
Prop
Type
See Dev servers and other ports for how forwarding works, and Keep a machine awake while connected for --keep-awake.
cp
stashbase vms cp [-r] <SOURCE> <DESTINATION>Copies files between this computer and a machine, like scp. Name the machine side as ID:path, or :path to pick the machine from a list (in scripts, pass the ID). Paths on the machine start in its home directory (/home/agent) unless they start with /. Missing folders on the machine are created when you upload, so :project/src works even if project does not exist yet. It starts or resumes the machine first and uses the same short-lived certificate as connect, so there is no key to set up.
stashbase vms cp ./notes.md :notes.md # upload
stashbase vms cp -r ./src :project/src # upload a folder (creates project/ if needed)
stashbase vms cp :project/report.pdf . # download
stashbase vms cp ./notes.md vm_abc123:notes.md # a specific machineProp
Type
Exactly one side is a machine; copying between two machines is not supported. What you download from the machine counts toward the workspace's traffic.
create
stashbase vms create [--location us|eu|asia] [--name <NAME>] [--autosuspend on|off] [--wait]Creating takes about a minute. Without --wait, create returns as soon as the machine is recorded, while it is still being created; with it, create returns once the machine is running and ready to connect.
Prop
Type
If the answer to a create is lost, or you press Ctrl+C while it runs, the machine may have been created anyway. The CLI says so; check stashbase vms list before trying again, so you do not end up with a second machine.
rename
stashbase vms rename <ID> <NAME>Changes the name shown in the dashboard and the CLI: up to 40 letters, numbers, spaces, dots, dashes or underscores. "" removes the name. Inside the machine, the prompt shows its ID, which never changes.
list, info and metrics
stashbase vms list # your machines
stashbase vms info <ID> # a machine's details and how to connect
stashbase vms metrics <ID> # CPU, memory and disk of a running machinestart, stop and delete
stashbase vms start <ID> # resume or start a machine without connecting (alias: resume)
stashbase vms stop <ID> # shut it down, keeping its disk
stashbase vms delete <ID> [--yes] # delete it and its disk for gooddelete asks for confirmation; --yes skips it and is required in scripts.
start, stop and delete return while the machine is still changing state, and so does create unless you pass --wait. connect waits until the machine is ready, so use it, create --wait or vms info before relying on the machine in a script.
autosuspend
stashbase vms autosuspend <ID> on|offon suspends the machine after a period without activity, keeping its session (the default); off keeps it running until you stop it or a usage limit is reached.
usage
stashbase vms usageShows the workspace's machine time and traffic for the current period, and the extra usage cap with what it has been used for. See Usage and billing.
In scripts
With --json, vms commands print their result as JSON. Failures go to stderr as JSON too, usually with an error.code:
{
"ok": false,
"error": {
"code": "conflict.virtual_machine_not_ready",
"message": "Virtual machine vm_abc123 is still starting; try connecting again shortly."
}
}Codes follow the same category.name format as the API. The ones most worth handling:
| Code | When | Commands |
|---|---|---|
request.outcome_unknown | A create got no clear answer. The machine may exist: check vms list before retrying. | create |
conflict.virtual_machine_not_ready | A wait ran out while the machine was still starting, stopping or being created. | create --wait, connect, cp |
conflict.invalid_virtual_machine_state | Creating or starting the machine failed. | create --wait, connect, cp |
validation.invalid_input | A missing or invalid option, such as --location in a script. | any |
Exit codes: 0 on success, 1 on failure, and 130 after Ctrl+C. connect -- <COMMAND> and cp pass on the exit code of the command or of scp.