> ## Documentation Index
> Fetch the complete documentation index at: https://docs.celesto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# smolvm sandbox env

> Use smolvm sandbox env to set, remove, and list environment variables inside a running sandbox over SSH or the SmolVM guest-agent channel.

`smolvm sandbox env` manages environment variables inside a sandbox. Variables are written to the guest so new login shells and later `vm.run(...)` calls can read them.

## Synopsis

```bash theme={null}
smolvm sandbox env set <sandbox> KEY=VALUE... [OPTIONS]
smolvm sandbox env unset <sandbox> KEY... [OPTIONS]
smolvm sandbox env list <sandbox> [OPTIONS]
```

<Note>
  Environment variable changes apply to new guest sessions. In an existing shell, run `source /etc/profile.d/smolvm_env.sh` to reload them.
</Note>

## Shared options

<ParamField path="--ssh-key" type="string">
  Path to an SSH private key when the command uses SSH.
</ParamField>

<ParamField path="--ssh-user" type="string" default="root">
  SSH user when the command uses SSH.
</ParamField>

<ParamField path="--comm-channel" type="string">
  Host-to-guest control channel. Use `ssh`, `vsock`, or omit it for auto-selection.
</ParamField>

<ParamField path="--json" type="flag">
  Print a JSON envelope instead of formatted text.
</ParamField>

## set

Set one or more variables:

```bash theme={null}
smolvm sandbox env set my-sandbox \
  OPENAI_API_KEY=sk-... \
  MODEL=gpt-4.1
```

Force vsock for a recent Linux image:

```bash theme={null}
smolvm sandbox env set my-sandbox APP_ENV=prod --comm-channel vsock
```

## unset

Remove variables:

```bash theme={null}
smolvm sandbox env unset my-sandbox OPENAI_API_KEY MODEL
```

## list

List variable names with values masked:

```bash theme={null}
smolvm sandbox env list my-sandbox
```

Show values when you are in a safe terminal:

```bash theme={null}
smolvm sandbox env list my-sandbox --show-values
```

## Key rules

Environment variable names must be valid shell identifiers, such as `OPENAI_API_KEY` or `APP_ENV`. Use `KEY=VALUE` pairs for `set`; values may be empty strings.

## Security notes

<Warning>
  Environment variables are stored in plaintext inside the sandbox. Avoid printing sensitive values in logs, and rotate credentials after sharing a sandbox with another workflow.
</Warning>

## Related commands

* [`smolvm sandbox shell`](/smolvm/cli/shell) - Open a shell that can read the variables
* [`smolvm sandbox file`](/smolvm/cli/file) - Copy config files into a sandbox
* [Control channel](/smolvm/concepts/control-channel) - Learn when SmolVM uses SSH or vsock
