fix: 修复 Ubuntu 24.04 下 setup-deploy-user.sh useradd 参数错误(--disabled-password 是 adduser 的)
构建 & 部署 BYW VoiceHub / Preflight 语法 & 构建检查 (push) Canceled after 0s
构建 & 部署 BYW VoiceHub / 构建并推送镜像 (push) Canceled after 0s
构建 & 部署 BYW VoiceHub / 部署到生产服务器 (push) Canceled after 0s

This commit is contained in:
2026-09-06 09:35:33 +08:00
parent a027816831
commit 7421906fb9
+11 -2
View File
@@ -42,8 +42,17 @@ command -v setfacl >/dev/null 2>&1 || {
# -------- 1. 建用户 -------- # -------- 1. 建用户 --------
if ! id -u "${DEPLOY_USER}" >/dev/null 2>&1; then if ! id -u "${DEPLOY_USER}" >/dev/null 2>&1; then
useradd --create-home --shell /usr/bin/bash --disabled-password "${DEPLOY_USER}" # 注意:Ubuntu 22.04/24.04 的 useradd 没有 --disabled-password 选项
ok "新建用户:${DEPLOY_USER}(无密码,仅 SSH key 登录)" # (那是 adduser 命令的参数,之前脚本写错了命令)。
# 这里用 useradd 原生参数:
# -m = 创建 home
# -s = 指定登录 shell
# -p '*' = 密码设置为「*」(锁定,禁止用密码登录,只能 SSH 密钥)
# 这样和之前「只允许 SSH 密钥登录、无密码」的意图完全一致。
useradd -m -s /usr/bin/bash -p '*' "${DEPLOY_USER}"
# Ubuntu/Debian 额外保险:锁定密码字段,避免 shadow 被改
usermod -L "${DEPLOY_USER}" 2>/dev/null || true
ok "新建用户:${DEPLOY_USER}(密码已锁定,仅 SSH key 登录)"
else else
info "用户 ${DEPLOY_USER} 已存在,跳过创建" info "用户 ${DEPLOY_USER} 已存在,跳过创建"
fi fi