VPS bootstrap: unlock the deploy user and give it passwordless sudo #1

Merged
smadzar merged 1 commits from fix/bootstrap-unlock-deploy-user into main 2026-10-26 14:01:21 +01:00
Owner

Problem

bootstrap-vps-ssh.sh stopped on a fresh Contabo Debian 13 with:

ERROR: Key login failed after hardening.

useradd leaves the new user's password field as !. Hardening sets UsePAM no, and then sshd refuses even key logins for that user (User deployer not allowed because account is locked). Root kept working because it has a password. This does not depend on the user name; deployer fails the same way.

The deploy user is key-only with no password, so sudo ./install-rubix.sh and sudo ./up.sh from the README could not work either.

Fix

  • Set the password field from ! to * (no password, not locked). Only an unset or locked field is changed; an existing password hash is left alone.
  • Add /etc/sudoers.d/90-rubix-<user> with NOPASSWD:ALL, checked with visudo -cf before it is moved in place. Install sudo if the image does not have it.

Test

Reproduced locally in debian:trixie: UsePAM no plus a ! user gives Permission denied (publickey). After the patched user-setup block, key login works and sudo -n id -u returns 0. Re-running the block is idempotent.

Recovering an already bootstrapped server

Root key login still works:

ssh -i ~/.ssh/<alias>.ed25519 root@<ip>
usermod -p '*' <user>
echo '<user> ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/90-rubix-<user> && chmod 440 /etc/sudoers.d/90-rubix-<user>
## Problem `bootstrap-vps-ssh.sh` stopped on a fresh Contabo Debian 13 with: ``` ERROR: Key login failed after hardening. ``` `useradd` leaves the new user's password field as `!`. Hardening sets `UsePAM no`, and then sshd refuses even key logins for that user (`User deployer not allowed because account is locked`). Root kept working because it has a password. This does not depend on the user name; `deployer` fails the same way. The deploy user is key-only with no password, so `sudo ./install-rubix.sh` and `sudo ./up.sh` from the README could not work either. ## Fix - Set the password field from `!` to `*` (no password, not locked). Only an unset or locked field is changed; an existing password hash is left alone. - Add `/etc/sudoers.d/90-rubix-<user>` with `NOPASSWD:ALL`, checked with `visudo -cf` before it is moved in place. Install `sudo` if the image does not have it. ## Test Reproduced locally in `debian:trixie`: `UsePAM no` plus a `!` user gives `Permission denied (publickey)`. After the patched user-setup block, key login works and `sudo -n id -u` returns `0`. Re-running the block is idempotent. ## Recovering an already bootstrapped server Root key login still works: ``` ssh -i ~/.ssh/<alias>.ed25519 root@<ip> usermod -p '*' <user> echo '<user> ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/90-rubix-<user> && chmod 440 /etc/sudoers.d/90-rubix-<user> ```
smadzar added 1 commit 2026-10-26 14:00:01 +01:00
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.
smadzar merged commit 9a568b3597 into main 2026-10-26 14:01:21 +01:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: swissdatabase/rubix-deploy#1