cli-anything-jumpserver 是做什麼的?
有狀態的命令列工具,用於管理 JumpServer 跳板機。透過 JumpServer REST API 管理資產、使用者、權限、帳號、連線、稽核等。
快速開始
# 安裝
cd agent-harness && pip install -e .
# 認證
cli-anything-jumpserver auth login --url https://jumpserver.example.com --username admin
# 列出主機
cli-anything-jumpserver asset list --type host
# 互動式 REPL 模式
cli-anything-jumpserver --interactive
代理程式使用指引
此 CLI 專為 AI 代理程式使用而設計。代理程式的關鍵功能:
JSON 輸出模式
所有命令都支援 --output json 以輸出機器可解析的內容:
cli-anything-jumpserver asset list --type host --output json
試執行模式
所有變更命令都支援 --dry-run 以預覽變更而不實際執行:
cli-anything-jumpserver asset create --name test --address 10.0.0.1 --platform 1 --dry-run --output json
環境變數
JUMPSERVER_URL- 預設 JumpServer URLJUMPSERVER_USERNAME- 預設使用者名稱JUMPSERVER_PASSWORD- 預設密碼
典型代理程式工作流程
1. 探索與盤點
# 檢查連線
cli-anything-jumpserver auth status --output json
# 列出所有主機
cli-anything-jumpserver asset list --type host --output json
# 取得資產詳細資訊
cli-anything-jumpserver asset get <ID> --type host --output json
# 列出所有使用者
cli-anything-jumpserver user list --output json
2. 使用者與權限管理
# 建立使用者
cli-anything-jumpserver user create --name "新使用者" --username newuser --email [email protected] --output json --dry-run
# 授予資產存取權限
cli-anything-jumpserver perm create --name "應用程式存取" --users "user1,user2" --assets "asset1,asset2" --output json --dry-run
# 驗證權限
cli-anything-jumpserver perm users <PERM_ID> --output json
3. 安全稽核
# 檢查失敗登入
cli-anything-jumpserver audit login --status failed --output json
# 檢視操作記錄
cli-anything-jumpserver audit operate --action delete --output json
# 檢查活躍連線
cli-anything-jumpserver session list --active --output json
# 檢視命令歷史
cli-anything-jumpserver session command list --risk 5 --output json
4. 連線管理
# 監控活躍連線
cli-anything-jumpserver session list --active --output json
# 檢查終端機健康狀態
cli-anything-jumpserver session terminal list --output json
cli-anything-jumpserver session terminal status <TERMINAL_ID> --output json
輸出格式
| 格式 | 旗標 | 使用案例 |
|---|---|---|
| 表格 | --output table(預設) | 人類可讀的顯示 |
| JSON | --output json | 代理程式使用、腳本處理 |
| YAML | --output yaml | 設定、可讀性 |
結束代碼
| 代碼 | 意義 |
|---|---|
| 0 | 成功 |
| 1 | CLI 錯誤(認證、API 等) |
| 2 | 使用錯誤(無效的選項/引數) |
| 130 | 中斷(Ctrl+C) |
檔案位置
| 路徑 | 用途 |
|---|---|
~/.jumpserver-cli/session.json | 認證連線 |
~/.jumpserver-cli/state.json | CLI 操作狀態 |