cli-anything-jumpserver 是做什么的?
用于JumpServer堡垒机的状态化CLI工具。通过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模式
所有变更命令支持 --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运行状态 |