Skip to main content

Synopsis

Description

The env command group provides subcommands for managing environment variables on running VMs. Variables are persisted in /etc/profile.d/smolvm_env.sh and automatically loaded for new SSH sessions.
Environment variable changes apply to new SSH sessions. Existing sessions require running source /etc/profile.d/smolvm_env.sh to pick up changes.

Subcommands

set

Set one or more environment variables on a VM. Variables are merged with existing ones.

Arguments

string
required
VM identifier
string[]
required
One or more KEY=VALUE pairs to set

Options

string
default:"~/.smolvm/keys/id_ed25519"
SSH private key path for connecting to the VM
string
default:"root"
SSH user to connect as

Examples

Set a single variable:
Output:
Set multiple variables:
Output:
Set variables with custom SSH credentials:

unset

Remove one or more environment variables from a VM.

Arguments

string
required
VM identifier
string[]
required
One or more variable names to remove

Options

string
default:"~/.smolvm/keys/id_ed25519"
SSH private key path for connecting to the VM
string
default:"root"
SSH user to connect as

Examples

Remove a single variable:
Output:
Remove multiple variables:
Output:
Attempt to remove non-existent variables:
Output:

list

List all SmolVM-managed environment variables on a VM.

Arguments

string
required
VM identifier

Options

flag
default:"false"
Show variable values (masked by default for security)
string
default:"~/.smolvm/keys/id_ed25519"
SSH private key path for connecting to the VM
string
default:"root"
SSH user to connect as

Examples

List variables (values masked):
Output:
List variables with values shown:
Output:
List variables on VM with no managed environment:
Output:

Environment Variable Validation

When setting variables, keys must follow these rules:
  • Must not be empty
  • Must follow shell variable naming conventions
  • Values can be any string (including empty strings)
Invalid key examples:

Persistence

Environment variables are stored in /etc/profile.d/smolvm_env.sh on the VM. This file:
  • Is sourced automatically for new login shells
  • Persists across VM restarts (if using persistent storage)
  • Can be manually sourced in existing sessions: source /etc/profile.d/smolvm_env.sh

Exit Codes

Common Workflows

Configure an AI agent with API credentials

Update database connection string

Audit environment variables

Security Considerations

Environment variables are stored in plaintext on the VM filesystem. For sensitive credentials:
  • Use dedicated secret management systems when possible
  • Restrict VM access appropriately
  • Use smolvm env list (without --show-values) to avoid accidental credential exposure in logs
  • Consider rotating credentials regularly