3 Commits

Author SHA1 Message Date
Ognjen Djukic a98b4207e6 VPS bootstrap: stop accepting the client's locale over SSH
Debian's sshd_config has AcceptEnv LANG LC_*, so a PC with e.g.
en_GB.UTF-8 makes bash print setlocale warnings on every login because
only en_US.UTF-8 is generated on the server. Comment out AcceptEnv during
hardening so the server keeps its own locale.
2026-10-26 14:36:49 +01:00
smadzar 9a568b3597 Merge pull request 'VPS bootstrap: unlock the deploy user and give it passwordless sudo' (#1) from fix/bootstrap-unlock-deploy-user into main
Reviewed-on: #1
2026-10-26 14:01:20 +01:00
Ognjen Djukic da7bf7107a VPS bootstrap: unlock the deploy user and give it passwordless sudo
useradd leaves the password field as '!'. After hardening sets UsePAM no,
sshd treats that account as locked and refuses even key logins, so the
bootstrap stopped with 'Key login failed after hardening'. Set the field to
'*' (no password, not locked).

The key-only deploy user has no password, so sudo for install-rubix.sh and
up.sh could never succeed. Add /etc/sudoers.d/90-rubix-<user> with NOPASSWD,
checked with visudo, and install sudo if the image lacks it.
2026-10-26 13:59:50 +01:00
+28
View File
@@ -313,6 +313,29 @@ elif getent group wheel >/dev/null 2>&1; then
usermod -aG wheel "${DEPLOY_USER}" usermod -aG wheel "${DEPLOY_USER}"
fi fi
# useradd leaves the password field as "!" (locked). With UsePAM no (set during
# hardening) sshd then rejects even key logins: "account is locked".
# "*" = no password but not locked.
if [[ "$(getent shadow "${DEPLOY_USER}" | cut -d: -f2)" =~ ^!+\*?$ ]]; then
usermod -p '*' "${DEPLOY_USER}"
fi
# Key-only user has no password to type, so sudo must not ask for one.
if [[ "${DEPLOY_USER}" != "root" ]]; then
if ! command -v sudo >/dev/null 2>&1 && command -v apt-get >/dev/null 2>&1; then
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq sudo >/dev/null
fi
SUDOERS="/etc/sudoers.d/90-rubix-${DEPLOY_USER}"
echo "${DEPLOY_USER} ALL=(ALL) NOPASSWD:ALL" > "${SUDOERS}.tmp"
chmod 440 "${SUDOERS}.tmp"
if visudo -cf "${SUDOERS}.tmp" >/dev/null; then
mv "${SUDOERS}.tmp" "${SUDOERS}"
else
rm -f "${SUDOERS}.tmp"
echo "WARN: sudoers check failed, ${DEPLOY_USER} has no passwordless sudo" >&2
fi
fi
install_key_for_user() { install_key_for_user() {
local u="$1" local u="$1"
local home_dir local home_dir
@@ -362,6 +385,11 @@ set_sshd_option ChallengeResponseAuthentication no
set_sshd_option PubkeyAuthentication yes set_sshd_option PubkeyAuthentication yes
set_sshd_option UsePAM no set_sshd_option UsePAM no
# Debian accepts LANG/LC_* from the client; a PC locale that is not generated
# here (e.g. en_GB.UTF-8) gives setlocale warnings on every login. The server
# uses its own en_US.UTF-8 (generated below) instead.
sed -i 's/^[[:space:]]*AcceptEnv[[:space:]]/#&/' "${SSHD}"
if [[ "${KEEP_ROOT}" == "yes" ]]; then if [[ "${KEEP_ROOT}" == "yes" ]]; then
set_sshd_option PermitRootLogin prohibit-password set_sshd_option PermitRootLogin prohibit-password
else else