This document explains all features available in OpsTerm, complete with usage examples and explanations.
| # | Feature | CLI Command | Category |
|---|---|---|---|
| 1 | ๐ค AI Chat | ai <prompt> |
Core |
| 2 | ๐ Smart SSH | ai ssh <server> |
Core |
| 3 | ๐ Multi-hop SSH | ai ssh <srv> --via <proxy> |
Core |
| 4 | ๐ SCP File Transfer | ai scp <src> <dst> |
Core |
| 5 | โก Workflow | ai run <name> |
Core |
| 6 | ๐ Vault | ai vault |
Core |
| 7 | ๐ Pipe Mode | cmd \| ai <prompt> |
Core |
| 8 | ๐ป Shell Integration | ai explain-last |
Shell |
| 9 | โจ๏ธ Tab Completion | ai completion bash\|zsh |
Utility |
| 10 | ๐ ๏ธ Server Manager | ai servers |
Management |
| 11 | ๐ Workflow Manager | ai workflows |
Management |
| 12 | โ๏ธ Config Manager | ai config |
Management |
| 13 | ๐ History | ai history |
Management |
| 14 | ๐ Init | ai init |
Setup |
Ask anything to AI directly from your terminal.
# Ask for a shell command
ai find log files larger than 1GB
# Output: $ find /var/log -type f -size +1G
# Ask for an explanation
ai explain what is a reverse proxy
# Generate a docker compose
ai create docker compose for nginx + postgres
# General question
ai how to check disk usage in linux
How it works:
1. Load config (API key, model, URL from config.yaml)
2. Build prompt + system message
3. HTTP POST to AI provider (OpenAI-compatible API)
4. Parse response JSON
5. Print to terminal
6. Save to history (SQLite)
7. Detect $ prefix โ offer auto-exec
Provider support: DeepSeek, OpenAI, OpenRouter, Ollama, vLLM, or anything that is OpenAI-compatible.
SSH into servers without memorizing IP addresses.
# Direct connect
ai ssh vps-main
# Fuzzy match โ partial name is enough
ai ssh vps
# List servers first
ai servers list
Server configuration in ~/.ai-workflows/servers.yaml:
servers:
vps-main:
host: "43.157.204.199"
user: "ubuntu"
port: 22
key: "~/.ssh/id_ed25519"
desc: "Main Tencent Cloud VPS"
Configurable fields:
- host โ IP or domain
- user โ SSH username
- port โ SSH port (default: 22)
- key โ path to private key
- proxy โ jump host (see multi-hop feature)
- desc โ description
SSH into internal servers that are only accessible through a jump host / bastion.
# Via CLI (per-call)
ai ssh internal-server --via bastion
# Via config (permanent)
ai ssh internal-server # automatically routes through bastion
Permanent config in servers.yaml:
servers:
bastion:
host: "123.123.123.123"
user: "ubuntu"
key: "~/.ssh/id_ed25519"
internal-server:
host: "10.0.0.5"
user: "ubuntu"
key: "~/.ssh/internal-key"
proxy: "bastion" # <-- automatically routes through bastion
How it works:
- Uses SSH -J (ProxyJump) flag
- Chains can be long: ssh -J jump1,jump2 server
- Proxy servers are resolved from servers.yaml as well
Upload/download files between local and remote servers using server:path syntax.
# Upload from local to server
ai scp ./config.yaml vps-main:/home/ubuntu/
# Download from server to local
ai scp vps-main:logs/app.log .
# Through a jump host
ai scp file.txt internal-server:/tmp/ --via bastion
How it works:
- Parse server:path โ resolve to user@host:path
- Same as SSH: supports proxy jump, key file, custom port
- Uses the system scp command via subprocess
Multi-step automation that runs several commands sequentially.
# Run a workflow
ai run deploy-app
# List workflows
ai workflows list
Example workflow:
workflows:
deploy-full:
desc: "Full deployment with file transfer"
steps:
- scp: "./docker-compose.yml"
to: "/home/ubuntu/app/docker-compose.yml"
ssh: vps-main
desc: "Upload compose file"
- ssh: vps-main
command: "cd /home/ubuntu/app && docker compose pull && docker compose up -d"
desc: "Pull images & restart"
- command: "echo 'โ
Deploy complete!'"
desc: "Notification"
Step types:
| Type | Format | Function |
|------|--------|----------|
| ssh | ssh: <server> + command: | Run command on remote server |
| scp | scp: <src> + to: <dst> + ssh: <server> | Transfer file to server |
| command | command: | Run local command |
| confirm | confirm: true | Request user confirmation before proceeding |
| wait | wait: <seconds> | Wait for a specified number of seconds |
Store credentials (API keys, passwords, tokens) in encrypted form.
# Init vault (set master password)
ai vault init
# Store a credential
ai vault set db_password "supersecret"
ai vault set github_token "ghp_..."
# Retrieve a credential
ai vault get db_password # Output: supersecret
# List keys
ai vault list
# Delete a key
ai vault rm db_password
# Lock vault (clear password from memory)
ai vault lock
Technical details:
- Encryption: AES-128-CBC via cryptography.fernet.Fernet
- Key derivation: PBKDF2-HMAC-SHA256, 600,000 iterations
- Master password: from OPSTERM_VAULT_PASSWORD env or prompt
- Fallback: if cryptography is not installed โ HMAC + XOR (less secure)
- Storage: encrypted JSON at ~/.ai-workflows/vault.json
Send command output to AI for analysis.
# Explain output
kubectl get pods | ai "are there any errors?"
docker logs webapp --tail 100 | ai "analyze these errors"
free -h | ai "is there enough memory?"
netstat -tlnp | ai "what ports are open?"
# Pipe without a specific prompt
df -h | ai
# AI auto-prompt: "Explain this output"
How it works:
1. Detect stdin (sys.stdin.isatty() == False)
2. Read stdin โ store as stdin_data
3. Build prompt: "Output from command:\n\n{stdin_data}\n\nQuestion: {prompt}"
4. Send to AI โ print response
Integration with Zsh shell for viewing and explaining the last command's output.
# Load in .zshrc
source ~/opsterm/zsh/opsterm.plugin.zsh
# View last command output
ai last
# Explain last command output using AI
ai explain-last
Features:
- ai-last โ alias for ai last
- ai-explain โ alias for ai explain-last
- ai-ti โ AI + Terminal Integration: ask AI, extract command, auto-execute
How it works:
- Zsh preexec hook โ saves command before it runs
- Last command output is stored in ~/.ai-workflows/last_output.txt
- ai explain-last โ reads file โ sends to AI
Auto-complete for bash and zsh โ no need to memorize server/workflow names.
# Bash
source <(ai completion bash)
# Zsh
source <(ai completion zsh)
# Or permanently:
echo 'source <(ai completion bash)' >> ~/.bashrc
echo 'source <(ai completion zsh)' >> ~/.zshrc
Completion contexts:
| Context | Completion |
|---------|------------|
| ai [Tab] | All subcommands |
| ai ssh [Tab] | Server names |
| ai run [Tab] | Workflow names |
| ai scp [Tab] | server: prefix |
| ai servers [Tab] | add, edit, rm, list |
| ai vault [Tab] | init, set, get, list, rm, lock |
| ai --via [Tab] | Proxy server names |
CRUD for servers โ save, edit, and delete server configurations.
# List all servers (with PROXY column)
ai servers list
# Output:
# NAME HOST USER PORT PROXY DESCRIPTION
# vps-main 43.157.204.199 ubuntu 22 โ Tencent Cloud VPS
# Add a new server (interactive)
ai servers add
# Edit a server
ai servers edit vps-main
# Delete a server
ai servers rm vps-main
Data stored in ~/.ai-workflows/servers.yaml.
CRUD for workflows โ save, edit, and delete workflows.
# List all workflows
ai workflows list
# Add a new workflow (interactive)
ai workflows add
# Edit a workflow (opens editor)
ai workflows edit deploy-app
# Delete a workflow
ai workflows rm deploy-app
Data stored in ~/.ai-workflows/workflows.yaml.
View and set OpsTerm configuration.
# View all config
ai config list
# Set a value
ai config set ai.model deepseek-chat
ai config set ai.api_url https://api.deepseek.com/v1/chat/completions
ai config set ai.temperature 0.3
ai config set shell.confirm_before_exec true
# Get a specific value
ai config get ai.model
Data stored in ~/.ai-workflows/config.yaml.
History of all commands that have been run.
# View last 20 entries
ai history
# View last 50 entries
ai history 50
Output:
[1] ๐ค 2026-05-24 15:30 [ai] how to check disk usage
[2] ๐ 2026-05-24 15:35 [ssh] vps-main
[3] โก 2026-05-24 15:40 [workflow] deploy-app
[4] ๐ 2026-05-24 15:45 [pipe] docker ps | ai error
Mode icons:
| Icon | Mode |
|------|------|
| ๐ค | AI chat |
| ๐ | SSH |
| โก | Workflow |
| ๐ | Pipe mode |
| ๐ป | Shell command |
| ๐ | SCP transfer |
| ๐ | Vault |
Data stored in SQLite: ~/.ai-workflows/history.db.
First-time setup โ creates default configuration files.
ai init
Created files:
- ~/.ai-workflows/config.yaml โ AI provider template
- ~/.ai-workflows/servers.yaml โ example server config
- ~/.ai-workflows/workflows.yaml โ example workflow config
| What You Want To Do | Command |
|---|---|
| SSH into a server | ai ssh vps-main |
| SSH through a bastion | ai ssh internal --via bastion |
| Upload a file | ai scp file.txt server:/path/ |
| Download a file | ai scp server:log.txt . |
| Deploy an app | ai run deploy-app |
| Check server health | ai run check-server |
| Ask for a command | ai how to check disk |
| Explain an error | docker logs -n50 \| ai "error?" |
| Explain last command | ai explain-last |
| Store a password | ai vault set db_pass |
| Retrieve a password | ai vault get db_pass |
| Auto-complete | ai [Tab] |
| View history | ai history |
| Setup from scratch | ai init |
ai exec <container> to jump directly into a container~/.ssh/configai ssh server --via jump1,jump2