1.1 KiB
1.1 KiB
2026-06-21 宝塔 bootstrap 非 root SSH 自动 sudo
摘要
ubuntu 等非 root SSH 用户(如 preset_id=2)可连机且宝塔已装,但 bootstrap 脚本未提权导致读 port.pl 失败,批量报 ssh_command_failed。现对 bootstrap、宝塔检测、面板地址探测、临时登录 SSH 统一 sudo -n bash -c。
动机
生产抽样 #135/#136/#147:SSH✅、sudo -n✅、root 下宝塔✅,非 sudo bootstrap 崩溃。
涉及文件
server/infrastructure/btpanel/ssh_bootstrap.py—wrap_sudo_nopasswd、ssh_sudo_requiredserver/infrastructure/btpanel/ssh_login.py— 检测/探测/登录命令提权tests/test_btpanel_ssh_bootstrap.pydocs/reports/2026-06-21-btpanel-ssh-timeout-servers.md— 超时机器运维清单
迁移 / 重启
- 部署 API 后对未配置服务器重跑批量 bootstrap。
验证
.venv/bin/pytest tests/test_btpanel_ssh_bootstrap.py tests/test_btpanel_ssh_login.py -q
POST /api/btpanel/servers/135/bootstrap # ubuntu 抽样
POST /api/btpanel/servers/batch-bootstrap {"all_unconfigured": true}