The Bolt CLI is a Python-based command-line interface for interacting with the Bolt server. It provides a user-friendly, context-aware interface to manage projects, sandboxes, port forwarding, resource limits, and shell access. The CLI supports all server features, displays accurate runtime information, and checks for server updates.
- Connection Management: Add and connect to Bolt servers with stored credentials.
- Project Management: Create, delete, and open projects.
- Sandbox Management: Create, delete, open, and list sandboxes within projects.
- Port Forwarding: Configure host-to-sandbox and sandbox-to-host port forwarding.
- Resource Limits: Set CPU and memory limits for projects.
- Shell Access: Connect to sandbox shells via a secure TCP connection with token authentication.
- Status Reporting: Display server and sandbox status with real-time system metrics.
- Update Checks: Check for server updates and display version information.
- Context-Aware Prompt: Reflects the current server, project, sandbox, or shell context.
- Python 3 and the
requestspackage. - Access to a running Bolt server.
pip3 install requestsCopy the bolt_cli.py script to a convenient location:
cp bolt_cli.py ~/bolt_cli.py
chmod +x ~/bolt_cli.pyOptionally, add it to your PATH:
sudo cp ~/bolt_cli.py /usr/local/bin/boltThe CLI stores server connections in ~/.bolt/config.json:
{
"servers": {
"server1": {
"ip": "127.0.0.1",
"username": "admin",
"password": "admin"
}
},
"current_server": "server1"
}- The file is created automatically with
0600permissions. - Credentials are prompted if not stored and saved securely.
Run the CLI interactively or with commands:
bolt
bolt <command> [args]- add : Add a new server connection.
- Example:
bolt add server1 127.0.0.1
- Example:
- connect : Connect to a server, prompting for credentials if needed.
- Example:
bolt connect server1
- Example:
- create project : Create a new project.
- Example:
create project project1
- Example:
- create sandbox [distro]: Create a sandbox in the current project.
- Example:
create sandbox sandbox1 debian:bullseye
- Example:
- delete project : Delete a project and its sandboxes.
- Example:
delete project project1
- Example:
- delete sandbox : Delete a sandbox from the current project.
- Example:
delete sandbox sandbox1
- Example:
- open project : Set the current project context.
- Example:
open project project1
- Example:
- open sandbox : Set the current sandbox context.
- Example:
open sandbox sandbox1
- Example:
- sandboxes: List sandboxes in the current project with runtime and distro.
- Example:
sandboxes
- Example:
- info: Show detailed info for the current sandbox (runtime, resources, ports).
- Example:
info
- Example:
- shell: Open a TCP shell to the current sandbox, prompting for a token.
- Example:
shell
- Example:
- forward <host_port> <container_port>: Forward a host port to a sandbox port.
- Example:
forward 10001 80
- Example:
- reverse <container_port> <host_port>: Forward a sandbox port to a host port.
- Example:
reverse 8080 10002
- Example:
- remove_forward <host_port>: Remove a host-to-sandbox port forwarding.
- Example:
remove_forward 10001
- Example:
- remove_reverse <container_port>: Remove a sandbox-to-host port forwarding.
- Example:
remove_reverse 8080
- Example:
- resources <cpu_quota_us> <memory_limit_mb>: Set resource limits for the current project.
- Example:
resources 50000 256
- Example:
- config : Update server admin credentials.
- Example:
config newadmin newpass
- Example:
- status: Show server status (sandboxes, CPU, RAM, storage).
- Example:
status
- Example:
- update: Show server update information.
- Example:
update
- Example:
- exit or quit: Exit the CLI.
- Example:
exit
- Example:
$ bolt
bolt $ add server1 127.0.0.1
Created new saved connection: server1 to 127.0.0.1!
bolt $ connect server1
Username for server1: admin
Password for server1:
Welcome to bolt v1.0.0
Update available: version 1.0.1, run 'update' to see more info.
0 Sandboxes running | Host Info: 0.0% CPU | 0.0% RAM | 0.0% STORAGE
bolt running for 00:00:01
[server1] $ create project project1
Created project: project1
[server1] $ open project project1
[server1/project1] $ create sandbox sandbox1
Created sandbox: sandbox1 from base image: debian:bullseye
[server1/project1] $ sandboxes
sandbox1 - debian:bullseye - Running for 00:00:02
[server1/project1] $ open sandbox sandbox1
[project1/sandbox1] $ info
sandbox1 - debian:bullseye - Running for 00:00:02
0.0% CPU | 0.0% RAM | 0.0% STORAGE
Port mappings: {}
Reverse port mappings: {}
[project1/sandbox1] $ forward 10001 80
Port 10001 forwarded to 80
[project1/sandbox1] $ reverse 8080 10002
Port 8080 forwarded to host 10002
[project1/sandbox1] $ resources 50000 256
Resource limits updated: CPU quota 50000us, memory limit 256MB
[project1/sandbox1] $ shell
Enter token: <token_from_server>
Bolt Shell
[sandbox1/shell] $ echo hi
hi
[sandbox1/shell] $ exit
[project1/sandbox1] $ remove_forward 10001
Port forwarding for 10001 removed
[project1/sandbox1] $ delete sandbox sandbox1
Deleted sandbox: sandbox1
[project1/sandbox1] $ exit
[server1/project1] $ delete project project1
Deleted project: project1
[server1] $ config newadmin newpass
Configuration updated successfully
[server1] $ exit- HTTPS: The CLI connects to the server over HTTPS but disables certificate verification for self-signed certificates. In production, ensure the server uses a trusted certificate.
- Shell Authentication: The shell requires a server-provided token, valid for 1 hour.
- Config Security: The
~/.bolt/config.jsonfile is stored with0600permissions to protect credentials. - Input Sanitization: All inputs are sanitized to prevent injection attacks.
- Connection Issues: Ensure the server is running and accessible on port 5000. Check firewall settings.
- Authentication Errors: Verify credentials in
~/.bolt/config.jsonor provide correct ones when prompted. - Shell Issues: Ensure the token is correct and the shell port (20001–25000) is open.
- Certificate Warnings: If using a self-signed certificate, the CLI disables verification. Update the server to use a trusted certificate for production.