Files
Nexus/docs/changelog/2026-05-23-ssh-exec-no-8601.md
2026-07-08 22:31:31 +08:00

40 lines
1.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 2026-05-23 — 脚本/健康检查改 SSH,弱化 8601
## 摘要
远程脚本执行与手动健康检查改为经 **SSH22**Agent 仅负责 **HTTPS 出站心跳(443**。子机 Agent HTTP 默认只监听 `127.0.0.1:8601`**不要求**公网放行 8601。
## 动机
大量宝塔子机未开放 8601;推送与文件已走 SSH。统一命令通道为 SSH,监控仍靠 Agent 心跳,减少防火墙与双通道维护成本。
## 涉及文件
- `server/application/services/script_service.py``_call_ssh_exec`,移除 Agent HTTP 执行路径
- `server/application/services/server_service.py``check_all_servers` 改 SSH 探测
- `server/infrastructure/ssh/remote_probe.py` — 新增 SSH 健康/指标探测
- `server/api/servers.py` — 健康检查 API 文档说明
- `web/agent/install.sh` — Python 3.12 venv、127.0.0.1 绑定、不再自动放行公网 8601
- `web/app/servers.html` — 安装说明文案
- `server/config.py` — 注释
## 端口模型(变更后)
| 方向 | 端口 | 用途 |
|------|------|------|
| 子机 → 中心 | 443 出站 | Agent 心跳、长任务 curl 回调 |
| 中心 → 子机 | 22 入站 | 推送、文件、脚本、手动健康检查 |
| 127.0.0.1:8601 | 仅本机 | Agent 进程(可选,不暴露公网) |
## 迁移 / 重启
- 需重启 Nexus 后端以加载 Python 变更
- 已装 Agent:建议重装或手动改 systemd 为 `127.0.0.1` + venv**不必**再开公网 8601
- 确保各服务器 SSH 凭据可用(与推送相同)
## 验证
1. 子机 Agent 运行:`journalctl -u nexus-agent -f`,心跳 200
2. 未开公网 8601 时:脚本页执行命令应成功(`channel: ssh`
3. `POST /api/servers/check` 返回 `channel: ssh``status: online`SSH 可达时)