From c0799ad5ee182ce2de849066ebfce7a302e19447 Mon Sep 17 00:00:00 2001 From: 247LIKE <54342887+247like@users.noreply.github.com> Date: Thu, 18 Dec 2025 20:17:10 +0800 Subject: [PATCH] Fix user account locking and update SSH settings Unlock user account by clearing password for SSH key usage. --- init.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/init.sh b/init.sh index 091f62e..1351f59 100644 --- a/init.sh +++ b/init.sh @@ -1215,6 +1215,10 @@ safe_ensure_user() { [ "$user_created" -eq 1 ] || { err "$(msg ERR_USER_CREATE_FAIL)"; return 1; } id "$user" >/dev/null 2>&1 || { err "$(msg ERR_USER_VERIFY_FAIL)"; return 1; } + # [FIX] 解锁用户账户,防止因 shadow 密码锁定导致 sudo NOPASSWD 失效 + # 使用 passwd -d 清除密码(变为无密码状态),配合 SSH Key 使用是安全的,且能让 PAM 通过账户检查 + passwd -d "$user" >/dev/null 2>&1 || usermod -U "$user" >/dev/null 2>&1 || true + safe_configure_sudo "$user" || true return 0 } @@ -1583,6 +1587,7 @@ build_block() { if [ "$KEY_OK" = "y" ]; then echo "PasswordAuthentication no" + echo "PermitEmptyPasswords no" echo "ChallengeResponseAuthentication no" echo "PubkeyAuthentication yes" # [SEC-FIX] Add KbdInteractiveAuthentication no for true key-only auth