# gosh **Repository Path**: 3155612/gosh ## Basic Information - **Project Name**: gosh - **Description**: 基于ssh协议的运维工具,支持批量远程执行命令,下发文件、启动代理 - **Primary Language**: Go - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 11 - **Created**: 2023-12-22 - **Last Updated**: 2026-04-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 0. 介绍 Gosh 是由golang编写的集成运维常用功能的小工具,基于ssh协议完成远程主机批量执行命令、下发文件、ssh端口转发功能。支持本地 SQLite 数据库管理资产,并提供 Web UI 通过浏览器进行资产管理。 ```text [root@duduniao ~]# gosh --help 基于ssh协议的批处理工具 Usage: gosh [command] Available Commands: cmd 连接远程服务器并执行shell命令 completion Generate the autocompletion script for the specified shell help Help about any command inventory 操作本地主机信息数据库 login 使用ssh协议登录远程服务器 proxy 将远程服务TCP端口代理到本地 pull 批量拉取远程主机文件到本地 push 批量发送文件到远程主机 web 启动 Web 服务,通过浏览器管理资产 Flags: -h, --help help for gosh -v, --version version for gosh Use "gosh [command] --help" for more information about a command. ``` --- # 1. 配置命令补全功能 ```text [root@duduniao ~]# gosh completion Generate the autocompletion script for gosh for the specified shell. See each sub-command's help for details on how to use the generated script. Usage: gosh completion [command] Available Commands: bash Generate the autocompletion script for bash fish Generate the autocompletion script for fish powershell Generate the autocompletion script for powershell zsh Generate the autocompletion script for zsh Flags: -h, --help help for completion ``` 以Linux的Bash为例: ```text # 将生成的补全脚本放入 /etc/bash_completion.d 下 [root@duduniao ~]# gosh completion bash > /etc/bash_completion.d/gosh # 退出当前shell后,重新打开终端,可以使用 tab 完成命令补全 [root@duduniao ~]# gosh cmd (连接远程服务器并执行shell命令) login (使用ssh协议登录远程服务器) completion (Generate the autocompletion script for the specified shell) proxy (将远程服务TCP端口代理到本地) help (Help about any command) pull (批量拉取远程主机文件到本地) inventory (操作本地主机信息数据库) push (批量发送文件到远程主机) ``` --- # 2. Gosh 本地数据库操作 Gosh 为了管理复杂多地区环境,Gosh使用本地 sqlite3 数据库来存储服务器信息,并且提供增删改查功能,用户可以根据需求每天从CMDB同步到本地
为了使用gosh数据库功能,需要设置两个环境变量,可以将其写入到 ~/.bash_profile ```text export GOSH_DB_USED=true export GOSH_DB_FILE=~/.config/gosh.db ``` ```text [root@duduniao ~]# gosh inventory --help 操作本地主机信息数据库 Usage: gosh inventory [flags] gosh inventory [command] Available Commands: delete 批量删除数据库中的主机数据 export 根据条件导出本地主机信息 get 根据条件查询本地主机信息 import 批量导入主机和跳板机信息,如果数据库存在则更新,不存在则创建 Flags: -h, --help help for inventory Use "gosh inventory [command] --help" for more information about a command ``` ## 2.1. 数据导入 Gosh 支持从 .xlsx 格式文件导入数据 ```text [root@duduniao ~]# gosh inventory import --help 执行该命令必须要提前设置环境变量: GOSH_DB_USED=true # 启用数据库 GOSH_DB_FILE=xxx.db # 指定SQLite数据库存放路径,默认: ~/.config/gosh.db 自动读取名为 bastion 的sheet作为 bastion 数据源,并跳过第一行(默认为title) 自动读取名为 host 的sheet作为 host 数据源,并跳过第一行(默认为title) Examples: # 从excel文件导入跳板机和服务器信息 gosh inventory -f /mnt/c/Users/test/Downloads/gosh.xlsx Usage: gosh inventory import -f [flags] Flags: -f, --file string 导入的文件 -h, --help help for import ``` ## 2.2. 数据查询 ```text [root@duduniao ~]# gosh inventory get --help 执行该命令必须要提前设置环境变量: GOSH_DB_USED=true # 启用数据库 GOSH_DB_FILE=xxx.db # 指定SQLite数据库存放路径,默认: ~/.config/gosh.db Note: 因为考虑到性能问题,不支持 模糊匹配, 取反等操作 Examples: # 查询全部跳板机信息: ~ gosh inventory get -t bastion # 查询腾讯上海跳板机信息: ~ gosh inventory get -t bastion -l vendor=tencent -l region=shanghai # 查询指定IP的跳板机 ~ gosh inventory get -t bastion -l private_ip=127.0.0.1 # 只显示 private_ip 和 vendor 字段(逗号分隔): ~ gosh inventory get --print.field private_ip,vendor # 输出为 JSON 格式(适合 jq 处理): ~ gosh inventory get --output json --print.field private_ip,vendor | jq '.[].private_ip' # 输出为空格分隔的 text 格式,不显示 header(适合 awk/cut): ~ gosh inventory get --output text --no-header --print.field private_ip,ssh_user Usage: gosh inventory get [-t host|bastion] [-l k1=v1] [-l k2=v2] ... [flags] Flags: -h, --help help for get -l, --label strings 查询条件 --no-header 不显示 header(sheet/text 格式有效) --output string 输出格式:sheet(默认)/ json / text (default "sheet") --print.field strings 指定导出字段,如 private_ip,vendor(为空则输出全部) -t, --type string 导入的数据类型,支持bastion和host (default "host") ``` host 类型可用字段:`no`, `vendor`, `region`, `project`, `env`, `app`, `private_ip`, `public_ip`, `connect_ip`, `ssh_user`, `ssh_port`, `ssh_key_file`, `bastion_ip` bastion 类型可用字段:`no`, `vendor`, `region`, `connect_ip`, `private_ip`, `public_ip`, `ssh_user`, `ssh_port`, `ssh_key_file` ## 2.3. 数据删除 ```text [root@duduniao ~]# gosh inventory delete --help 执行该命令必须要提前设置环境变量: GOSH_DB_USED=true # 启用数据库 GOSH_DB_FILE=xxx.db # 指定SQLite数据库存放路径,默认: ~/.config/gosh.db Note: 因为考虑到性能问题,不支持 模糊匹配。为了避免误操作清空数据库,要求必须填写条件。 默认情况下只显示将被删除的记录数量,需要加 --force 才会真正执行删除。 Examples: # 预览将要删除腾讯上海的服务器数量(不执行实际删除): ~ gosh inventory delete -t host -l region=shanghai -l vendor=tencent # 确认删除腾讯上海的服务器: ~ gosh inventory delete -t host -l region=shanghai -l vendor=tencent --force # 删除指定IP的跳板机 ~ gosh inventory delete -t bastion -l private_ip=127.0.0.1 --force Usage: gosh inventory delete [-t host|bastion] [-l k1=v1] [-l k2=v2] [flags] Flags: --force 跳过预览直接执行删除(默认仅显示将删除的记录数) -h, --help help for delete -l, --label strings 查询条件 -t, --type string 删除的数据类型,支持bastion和host (default "host") ``` ## 2.4. 数据导出 ```text [root@duduniao ~]# gosh inventory export --help 执行该命令必须要提前设置环境变量: GOSH_DB_USED=true # 启用数据库 GOSH_DB_FILE=xxx.db # 指定SQLite数据库存放路径,默认: ~/.config/gosh.db Note: 因为考虑到性能问题,不支持 模糊匹配, 取反等操作。 当主机信息发生变更时,可以先导入这部分机器,然后在 excel 中修改完毕后再导入 Examples: # 导出全部信息: ~ gosh inventory export -f res.xlsx # 导出腾讯上海主机信息: ~ gosh inventory export -t host -l vendor=tencent -l region=shanghai -f res.xlsx # 查询指定IP的跳板机 ~ gosh inventory export -t bastion -l private_ip=127.0.0.1 -f res.xlsx Usage: gosh inventory export -f [-t host|bastion|all] [-l k1=v1] [-l k2=v2] ... [flags] Flags: -f, --file string 导出的文件路径 (default "gosh.xlsx") -h, --help help for export -l, --label strings 查询条件 -t, --type string 导入的数据类型,支持bastion,host,all (default "all") ``` --- # 3. 批量执行shell命令 Gosh 支持指定跳板机,但是目前只支持一个跳板机,暂时不支持多级跳板机操作 ```text [root@duduniao ~]# gosh cmd --help 批量连接远程服务器并执行shell命令,最多支持使用一层跳板机 可以从本地数据库读取主机连接信息,比如 ssh_user, ssh_port, bastion_ip 等,减少每次传递参数的繁琐流程,使用数据库前提: 1. 设置数据库环境变量 GOSH_DB_USED=true # 启用数据库 GOSH_DB_FILE=xxx.db # 指定SQLite数据库存放路径,默认: ~/.config/gosh.db 2. 使用 gosh inventory import 导入数据 Note: 1. 优先级: 命令行 > 数据库,比如命令行传递 --user root,会覆盖数据库中的 ssh_user 2. 默认值:如果命令行没有指定,数据库也没指定,那么以下字段使用默认值: user/bastion.user: 当前运行gosh的用户名 port/bastion.port: 22 key/bastion.key: ~/.ssh/id_rsa 3. 为了避免特殊情况下,数据库中同一个 ssh_ip 有多条记录(不同地区采用的私有网络地址重复),可使用 --label 筛选,取第一个匹配数据 因为考虑到性能问题,不支持模糊匹配 Examples: # 输出无法连通的机器IP地址 ~ gosh cmd -i ip.txt -u ops -p 2333 --print.status failed --print.field ip "id" # 读取 ip.txt 文件中的列表,并检查主机名, 提升至30并发: ~ gosh cmd -i ip.txt -f 30 "hostname" | xargs -n 2 | column -t # 检查服务状态 ~ gosh cmd -i ip.txt "sudo systemctl is-active firewalld.service; sudo systemctl is-enabled firewalld.service"| xargs -n 3 | column -t # 远程执行脚本,并打印执行失败的主机执行信息 ~ gosh cmd -i ip.txt --print.status failed "sudo bash /tmp/install.sh" # 读取 ip.txt 文件中的列表,并远程扫描 /data 数据目录大小: ~ gosh cmd -i ip.txt -u ops -p 2333 -k ~/.ssh/k1 --bastion.host 10.100.100.100 "df -h /data/ | awk 'NR==2{print \$2}'" # 从命令行直接读取IP列表,可以使用 echo 'xxx xxx xxx' | xargs | tr " " "," 生成列表 ~ gosh cmd -H 127.0.0.1,127.0.0.2,127.0.0.3,127.0.0.4,127.0.0.5 "grep '^#PermitRootLogin' /etc/ssh/sshd_config" # 将每台机器的执行结果保存到 /tmp/results 目录(以 IP 命名) ~ gosh cmd -i ip.txt "hostname" --output-dir /tmp/results Usage: gosh cmd {-i hosts.txt|-H host01,host02,...} [flags] commands... Flags: --bastion.host string 指定跳板机IP --bastion.key string 指定跳板机ssh私钥 --bastion.key.passphrase string 指定跳板机ssh私钥的密码 --bastion.password string 指定跳板机密码 --bastion.port int 指定跳板机端口 --bastion.user string 指定跳板机用户,默认当前用户 -t, --connect.timeout duration ssh连接超时时间 (default 5s) -f, --fork int 指定并发数量 (default 10) -h, --help help for cmd -H, --host string 指定主机列表,使用逗号分隔 -i, --inventory string 指定主机清单列表文件,# 开头为注释 -k, --key string 指定ssh私钥 --key.passphrase string ssh私钥的密码 -l, --label strings 指定标签选择器 --output-dir string 将每台主机的 stdout/stderr 保存到该目录(以 IP 命名) -P, --password string 远程ssh用户的密码 -p, --port int 指定远程主机ssh的端口 --print.field strings 选择打印的消息字段 (default [ip,stdout,stderr]) --print.status strings 选择打印成功或者失败的消息 (default [failed,succeed]) -u, --user string 远程ssh用户,默认当前用户 ``` --- # 4. 批量下发文件 Gosh支持基于sftp协议下发多个文件或者目录到远程主机,虽然支持下发目录,但是对于有特殊权限的目录,建议打包后下发到目标主机
```text [root@duduniao ~]# gosh push --help 批量发送文件到远程主机,最多支持使用一层跳板机。 可以从本地数据库读取主机连接信息,比如 ssh_user, ssh_port, bastion_ip 等,减少每次传递参数的繁琐流程,使用数据库前提: 1. 设置数据库环境变量 GOSH_DB_USED=true # 启用数据库 GOSH_DB_FILE=xxx.db # 指定SQLite数据库存放路径,默认: ~/.config/gosh.db 2. 使用 gosh inventory import 导入数据 Note: 1. 优先级: 命令行 > 数据库,比如命令行传递 --user root,会覆盖数据库中的 ssh_user 2. 默认值:如果命令行没有指定,数据库也没指定,那么以下字段使用默认值: user/bastion.user: 当前运行gosh的用户名 port/bastion.port: 22 key/bastion.key: ~/.ssh/id_rsa 3. 为了避免特殊情况下,数据库中同一个 ssh_ip 有多条记录(不同地区采用的私有网络地址重复),可使用 --label 筛选,取第一个匹配数据 因为考虑到性能问题,不支持模糊匹配 虚拟机支持的筛选字段: vendor,region,private_ip,public_ip,user,port,key,bastion,connect_ip 4. push 命令传输速度很慢,不适合传输大文件,速度远低于 scp 命令 5. 将本地目录传输到远程时,如果本地目录以 / 结尾,则拷贝目录下子文件 Examples: # 读取 ip.txt 文件中的列表,下发系统参数配置到远程主机上: ~ gosh push -i ip.txt ops-sysctl.conf /etc/sysctl.d/ # 读取 ip.txt 文件中的列表,并推送nginx配置到远程主机: ~ gosh push -i ip.txt -u ops -p 2333 -k ~/.ssh/k1 --bastion.host 10.100.100.100 nginx.conf conf.d ssl /etc/nginx/ # 读取 ip.txt 文件中的列表,并推送压缩文件到远程主机: ~ gosh push -i ip.txt -u ops -p 2333 tarball/*.tar.gz /opt/src/ # 读取 ip.txt 文件中的列表,并推送filebeat目录下配置文件到远程主机: ~ gosh push -i ip.txt -u ops -p 2333 config/filebeat/ /opt/apps/filebeat/inputs.d/ Usage: gosh push {-i hosts.txt|-H host01,host02,...} [flags] localFile... remoteDirectory Flags: --bastion.host string 指定跳板机IP --bastion.key string 指定跳板机ssh私钥 --bastion.key.passphrase string 指定跳板机ssh私钥的密码 --bastion.password string 指定跳板机密码 --bastion.port int 指定跳板机端口 --bastion.user string 指定跳板机用户,默认当前用户 -t, --connect.timeout duration ssh连接超时时间 (default 5s) -f, --fork int 指定并发数量 (default 10) -h, --help help for push -H, --host string 指定主机列表,使用逗号分隔 -i, --inventory string 指定主机清单列表文件,# 开头为注释 -k, --key string 指定ssh私钥 --key.passphrase string ssh私钥的密码 -l, --label strings 指定标签选择器 -P, --password string 远程ssh用户的密码 -p, --port int 指定远程主机ssh的端口 --print.field strings 选择打印的消息字段 (default [ip,stdout,stderr]) --print.status strings 选择打印成功或者失败的消息 (default [failed,succeed]) -u, --user string 远程ssh用户,默认当前用户 ``` --- # 5. 拉取文件 ```text [root@duduniao ~]# gosh pull --help 批量拉取远程主机文件到本地,最多支持使用一层跳板机。 可以从本地数据库读取主机连接信息,比如 ssh_user, ssh_port, bastion_ip 等,减少每次传递参数的繁琐流程,使用数据库前提: 1. 设置数据库环境变量 GOSH_DB_USED=true # 启用数据库 GOSH_DB_FILE=xxx.db # 指定SQLite数据库存放路径,默认: ~/.config/gosh.db 2. 使用 gosh inventory import 导入数据 Note: 1. 优先级: 命令行 > 数据库,比如命令行传递 --user root,会覆盖数据库中的 ssh_user 2. 默认值:如果命令行没有指定,数据库也没指定,那么以下字段使用默认值: user/bastion.user: 当前运行gosh的用户名 port/bastion.port: 22 key/bastion.key: ~/.ssh/id_rsa 3. 为了避免特殊情况下,数据库中同一个 ssh_ip 有多条记录(不同地区采用的私有网络地址重复),可使用 --label 筛选,取第一个匹配数据 因为考虑到性能问题,不支持模糊匹配 4. 需要注意文件的访问权限问题 Examples: # 拉取远程主机的文件到本地当前目录下,程序会在当前目录下创建一个以远程主机IP地址为名称的目录 ~ gosh pull -i ip.txt /etc/nginx/conf.d /etc/nginx/nginx.conf ./ # 拉取远程主机上的错误日志到本地logs目录下 ~ gosh pull -i ip.txt /var/log/nginx/error.log logs/ Usage: gosh pull {-i hosts.txt|-H host01,host02,...} [flags] remoteFile|remoteDir... LocalDirectory Flags: --bastion.host string 指定跳板机IP --bastion.key string 指定跳板机ssh私钥 --bastion.key.passphrase string 指定跳板机ssh私钥的密码 --bastion.password string 指定跳板机密码 --bastion.port int 指定跳板机端口 --bastion.user string 指定跳板机用户,默认当前用户 -t, --connect.timeout duration ssh连接超时时间 (default 5s) -f, --fork int 指定并发数量 (default 10) -h, --help help for pull -H, --host string 指定主机列表,使用逗号分隔 -i, --inventory string 指定主机清单列表文件,# 开头为注释 -k, --key string 指定ssh私钥 --key.passphrase string ssh私钥的密码 -l, --label strings 指定标签选择器 -P, --password string 远程ssh用户的密码 -p, --port int 指定远程主机ssh的端口 --print.field strings 选择打印的消息字段 (default [ip,stdout,stderr]) --print.status strings 选择打印成功或者失败的消息 (default [failed,succeed]) -u, --user string 远程ssh用户,默认当前用户 ``` --- # 6. 端口转发 ```text [root@duduniao ~]# gosh proxy --help 将远程服务TCP端口代理到本地,方便服务调测。使用ssh工具实现本地端口转发和远程端口转发 可参考文档:https://www.yuque.com/duduniao/linux/nwsn6p#Kt3rn Usage: gosh proxy -H host [flags] [-l local] -r remote Flags: -j, --bastion.host string 指定跳板机IP --bastion.key string 指定跳板机ssh私钥 (default "~/.ssh/id_rsa") --bastion.key.passphrase string 指定跳板机ssh私钥的密码 --bastion.password string 指定跳板机密码 --bastion.port int 指定跳板机SSH端口 (default 22) --bastion.user string 指定跳板机SSH用户,默认当前用户 -h, --help help for proxy -H, --host string 转发请求的远程主机 -k, --key string 指定ssh私钥 (default "~/.ssh/id_rsa") --key.passphrase string ssh私钥的密码 -l, --local string 本地监听端口 (default "127.0.0.1:10080") -P, --password string 远程ssh用户的密码 -p, --port int 指定远程主机ssh的端口 (default 22) --protocol string 远程服务器的通宵协议,tcp,tcp4,tcp6,unix (default "tcp4") -r, --remote string 目标服务地址 -t, --timeout duration 连接超时时间,ssh连接和proxy转发超时 (default 5s) --type string 指定端口转发类型,local:本地端口转发,remote:远程端口转发 (default "local") -u, --user string 远程ssh用户,默认当前用户 ``` # 7. 登录服务器并打开交互式终端 ```text [root@duduniao ~]# gosh login --help 使用ssh协议登录远程服务器,最多支持使用一层跳板机 可以从本地数据库读取主机连接信息,比如 ssh_user, ssh_port, bastion_ip 等,减少每次传递参数的繁琐流程,使用数据库前提: 1. 设置数据库环境变量 GOSH_DB_USED=true # 启用数据库 GOSH_DB_FILE=xxx.db # 指定SQLite数据库存放路径,默认: ~/.config/gosh.db 2. 使用 gosh inventory import 导入数据 Note: 1. 优先级: 命令行 > 数据库,比如命令行传递 --user root,会覆盖数据库中的 ssh_user 2. 默认值:如果命令行没有指定,数据库也没指定,那么以下字段使用默认值: user/bastion.user: 当前运行gosh的用户名 port/bastion.port: 22 key/bastion.key: ~/.ssh/id_rsa 3. 为了避免特殊情况下,数据库中同一个 ssh_ip 有多条记录(不同地区采用的私有网络地址重复),可使用 --label 筛选,取第一个匹配数据 因为考虑到性能问题,不支持模糊匹配 Examples: # 登录 10.100.100.101 ~ gosh login -H 10.100.100.101 # 使用 ops 帐号并通过 2223 端口登录到 10.100.100.101 ~ gosh login -H 10.100.100.101 -u ops -p 2333 Usage: gosh login -H host [flags] Flags: -j, --bastion.host string 指定跳板机IP --bastion.key string 指定跳板机ssh私钥 --bastion.key.passphrase string 指定跳板机ssh私钥的密码 --bastion.password string 指定跳板机密码 --bastion.port int 指定跳板机SSH端口 --bastion.user string 指定跳板机SSH用户,默认当前用户 -h, --help help for login -H, --host string 需要登录的远程主机 -k, --key string 指定ssh私钥 --key.passphrase string ssh私钥的密码 -l, --label strings 指定标签选择器 -P, --password string 远程ssh用户的密码 -p, --port int 指定远程主机ssh的端口 -t, --timeout duration 连接超时时间,ssh连接和proxy转发超时 (default 5s) -u, --user string 远程ssh用户,默认当前用户 ``` --- # 8. Web 资产管理 Gosh 提供内置 Web UI,通过浏览器对 Host 和 Bastion 资产进行增删改查,并支持 Excel 导入/导出。前端页面已打包进二进制,无需额外部署。 ```text [root@duduniao ~]# gosh web --help 执行该命令必须要提前设置环境变量: GOSH_DB_USED=true # 启用数据库 GOSH_DB_FILE=xxx.db # 指定SQLite数据库存放路径,默认: ~/.config/gosh.db Examples: # 使用默认地址和端口启动: ~ gosh web # 指定监听地址和端口: ~ gosh web --address 0.0.0.0 --port 9090 # 启用 Token 认证(推荐监听非 127.0.0.1 时使用): ~ gosh web --address 0.0.0.0 --token mysecret Usage: gosh web [flags] Flags: --address string 监听地址 (default "127.0.0.1") -h, --help help for web --port int 监听端口 (default 8080) --token string Bearer Token 认证(不指定则不启用) ``` ## 8.1 认证说明 | 场景 | 行为 | |------|------| | 未指定 `--token` | 不启用认证,任何人可访问 | | 未指定 `--token` 且监听非 `127.0.0.1` | 启动时在 stderr 打印黄色 WARNING 提示 | | 指定 `--token` | 浏览器首次访问时弹出输入框,Token 保存在 localStorage,后续自动携带;输入错误会重新提示 | ## 8.2 功能说明 | 功能 | 说明 | |------|------| | 资产列表 | Host / Bastion 分 Tab 展示,支持按 vendor、region、project 等字段搜索过滤 | | 新增记录 | 点击"新增"按钮,通过表单填写字段后保存 | | 编辑记录 | 点击行末"编辑"按钮,修改字段后保存 | | 删除记录 | 点击行末"删除"按钮,确认后删除单条记录 | | 导入 Excel | 点击顶部"导入 Excel",上传 xlsx 文件批量导入(sheet 名须为 host / bastion) | | 导出 Excel | 点击顶部"导出 Excel",下载包含全部 host 和 bastion 数据的 xlsx 文件 | ## 8.3 REST API 后端同时暴露 REST API,可供脚本或其他工具调用。启用 `--token` 时,请求需携带 `Authorization: Bearer ` Header(`/api/ping` 除外): ```text GET /api/ping # 返回 {"token_required": true/false},不需要认证 GET /api/hosts # 查询 host 列表,支持 ?vendor=xx®ion=xx 等参数 POST /api/hosts # 新增 host(JSON body) PUT /api/hosts/:name # 更新指定 name 的 host DELETE /api/hosts/:name # 删除指定 name 的 host GET /api/bastions # 查询 bastion 列表 POST /api/bastions # 新增 bastion PUT /api/bastions/:connect_ip # 更新指定 connect_ip 的 bastion DELETE /api/bastions/:connect_ip # 删除指定 connect_ip 的 bastion POST /api/import # 上传 xlsx 文件(multipart form,字段名 file) GET /api/export?type=all # 下载 xlsx(type 支持 host / bastion / all) ```