CLI Reference
The knot command-line interface provides tools for managing servers, connecting to spaces, and automating workflows.
Server Commands
knot server
Start the knot server.
knot server --config knot.tomlOptions:
--config: Path to configuration file--validate: Validate configuration without starting server
knot scaffold
Generate configuration file templates.
# Generate server configuration
knot scaffold --server > knot.toml
# Generate agent configuration
knot scaffold --agent > agent.tomlknot genkey
Generate encryption key for configuration.
knot genkeyUse the output in the server.encrypt or server.cluster.key configuration fields.
Client Commands
knot connect
Connect to a knot server and authenticate.
knot connect https://knot.example.com:3000Credentials are stored in ~/.config/knot/knot.yml for subsequent commands.
Options:
--server-name: Name for this server connection (for managing multiple servers)
knot forward
Forward connections between local machine and spaces.
SSH Forwarding
knot forward ssh SPACE_NAMEUse with SSH ProxyCommand:
ssh -o ProxyCommand='knot forward ssh %h' user@spacenamePort Forwarding
knot forward port LOCAL_ADDR SPACE_NAME REMOTE_PORTExample:
knot forward port 127.0.0.1:8080 myspace 80knot tunnel
Create tunnels to expose services publicly.
knot tunnel PROTOCOL PORT TUNNEL_NAMEProtocols: http, https
Example:
knot tunnel http 8080 myappCreates tunnel at username-myapp.tunnel.example.com.
knot ssh-config
Manage SSH configuration entries for spaces.
# Add entries for all spaces
knot ssh-config update
# Remove all entries
knot ssh-config removeAutomatically updates ~/.ssh/config with ProxyCommand entries.
knot run
Execute commands in a space.
knot run SPACE_NAME COMMAND [ARGS...]Example:
knot run myspace ls -la /homeknot cp
Copy files between local machine, spaces, and between spaces.
# Copy to space
knot cp LOCAL_FILE SPACE_NAME:REMOTE_PATH
# Copy from space
knot cp SPACE_NAME:REMOTE_PATH LOCAL_FILE
# Copy between spaces
knot cp SOURCE_SPACE:SOURCE_PATH DEST_SPACE:DEST_PATHExamples:
# Local to space
knot cp config.json myspace:/etc/app/
# Space to local
knot cp myspace:/var/log/app.log ./logs/
# Space to space
knot cp frontend:/app/build backend:/var/www/htmlOptions:
--workdir,-w: Working directory for relative paths in space
Agent Commands
These commands run inside a space.
knot agent
Start the knot agent inside a container.
knot agent --config agent.tomlUsually started automatically by container entrypoint.
knot agent shutdown
Request space shutdown from inside the space.
knot agent shutdownknot agent restart
Request space restart from inside the space.
knot agent restartknot agent set-note
Set space note from inside the space.
knot agent set-note "Deployment completed"knot port
Agent port management for forwarding ports between spaces.
Forward Port
Forward a local port in the current space to a port in another space.
knot port forward LOCAL_PORT SPACE_NAME REMOTE_PORTExample:
knot port forward 8080 backend-api 3000Requirements:
- Both spaces must be running with active agents
- Spaces must be in the same zone
- Spaces must be owned by the same user
List Active Port Forwards
View all active port forwards from the current space.
knot port listStop Port Forward
Stop an active port forward.
knot port stop LOCAL_PORTExample:
knot port stop 8080Space Management
List Spaces
knot space listStart Space
knot space start SPACE_NAMEStop Space
knot space stop SPACE_NAMERestart Space
knot space restart SPACE_NAMEDelete Space
knot space delete SPACE_NAMECreate Space
knot space create SPACE_NAME TEMPLATE_NAMEGet Space Logs
knot space logs SPACE_NAMERun Command in Space
knot space run SPACE_NAME COMMAND [ARGS...]Run Script in Space
knot space run-script SPACE_NAME SCRIPT_NAME [ARGS...]Space File Operations
Read File from Space
Read file contents from a running space.
knot space read-file SPACE_NAME FILE_PATHExamples:
# Read a file
knot space read-file myspace /etc/hostname
# Redirect to local file
knot space read-file myspace /var/log/app.log > local.logWrite File to Space
Write content to a file in a running space.
# Write content directly
knot space write-file SPACE_NAME FILE_PATH --content "CONTENT"
# Read from stdin
echo "Hello World" | knot space write-file SPACE_NAME FILE_PATH --content -Examples:
# Write text directly
knot space write-file myspace /tmp/hello.txt --content "Hello World"
# Pipe from local file
cat config.json | knot space write-file myspace /etc/app/config.json --content -Options:
--content,-d: Content to write (use-to read from stdin)
Space Field Operations
Get Custom Field
knot space get-field SPACE_NAME FIELD_NAMESet Custom Field
knot space set-field SPACE_NAME FIELD_NAME VALUESpace Tunnel Port
Create a tunnel from a space port to a local port.
knot space tunnel-port SPACE_NAME REMOTE_PORT LOCAL_PORTScript Management
List Scripts
List all available scripts (user and global).
knot script listShows script name, description, active status, type, and discoverability.
Show Script Details
Display detailed information about a script including its content.
knot script show SCRIPT_NAMEDelete Script
Delete a script by name.
knot script delete SCRIPT_NAMEGlobal Options
Available for most commands:
--help: Show command help--version: Show version information--server-name: Select server connection (when managing multiple servers)
Configuration File
Client configuration is stored in ~/.config/knot/knot.yml:
servers:
default:
url: https://knot.example.com:3000
token: <auth-token>
production:
url: https://knot-prod.example.com:3000
token: <auth-token>Switch between servers using --server-name flag.
Environment Variables
KNOT_SERVER: Override server URLKNOT_TOKEN: Override authentication tokenKNOT_CONFIG: Override config file path
Exit Codes
0: Success1: General error2: Authentication error3: Connection error4: Not found error