Files
Nexus/docs/changelog/2026-06-21-btpanel-bootstrap-sudo.md
T
r 3195787461 fix(btpanel): 非 root SSH bootstrap 自动 sudo 提权
ubuntu 等用户免密 sudo 下宝塔已装但脚本未提权导致 ssh_command_failed;附 ssh_timeout 运维清单。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-21 10:40:46 +08:00

1.1 KiB
Raw Blame History

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/#147SSHsudo -n、root 下宝塔,非 sudo bootstrap 崩溃。

涉及文件

  • server/infrastructure/btpanel/ssh_bootstrap.pywrap_sudo_nopasswdssh_sudo_required
  • server/infrastructure/btpanel/ssh_login.py — 检测/探测/登录命令提权
  • tests/test_btpanel_ssh_bootstrap.py
  • docs/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}