Skip to content

Fix SSH logins into containers on Ubuntu 24.04 - #11

Merged
skokec merged 1 commit into
masterfrom
feat/ubuntu24-support
Jun 17, 2026
Merged

skokec merged 1 commit into
masterfrom
feat/ubuntu24-support

Conversation

@skokec

@skokec skokec commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Two Noble-specific regressions broke Permission denied (publickey):

  1. The 24.04 base image ships a default 'ubuntu' user/group at UID/GID
    1000. 02_user.sh runs adduser --uid=1000, which fails because the UID is taken; under set -e the whole startup aborted before the SSH key was installed (and before sshd started). Remove any user/group squatting on the requested UID/GID first. 22.04 has no user at 1000, so it was never affected.

  2. adduser --disabled-password leaves the shadow password as '!' (locked). OpenSSH 9.x (24.04) refuses all authentication -- including publickey -- for locked accounts ("account is locked"), whereas 8.x (22.04) only applied this to password auth. Swap '!' for '*': still no usable password, but the account is no longer treated as locked.

Verified end-to-end with real key logins on both ubuntu:24.04 and ubuntu:22.04 base images.

Claude-Session: https://claude.ai/code/session_01CQUc7qbigQhV69kdg16eLa

Two Noble-specific regressions broke `Permission denied (publickey)`:

1. The 24.04 base image ships a default 'ubuntu' user/group at UID/GID
   1000. 02_user.sh runs `adduser --uid=1000`, which fails because the UID
   is taken; under `set -e` the whole startup aborted before the SSH key
   was installed (and before sshd started). Remove any user/group squatting
   on the requested UID/GID first. 22.04 has no user at 1000, so it was
   never affected.

2. `adduser --disabled-password` leaves the shadow password as '!'
   (locked). OpenSSH 9.x (24.04) refuses all authentication -- including
   publickey -- for locked accounts ("account is locked"), whereas 8.x
   (22.04) only applied this to password auth. Swap '!' for '*': still no
   usable password, but the account is no longer treated as locked.

Verified end-to-end with real key logins on both ubuntu:24.04 and
ubuntu:22.04 base images.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CQUc7qbigQhV69kdg16eLa
Copilot AI review requested due to automatic review settings June 17, 2026 15:34
@skokec
skokec merged commit 771b667 into master Jun 17, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to restore SSH public-key logins into containers based on Ubuntu 24.04 by ensuring user provisioning doesn’t abort on UID/GID 1000 collisions and by avoiding OpenSSH 9.x’s “account is locked” rejection for --disabled-password accounts.

Changes:

  • Update container startup user provisioning to remove a pre-existing default user/group occupying the requested UID/GID (notably 1000 on Ubuntu 24.04 images).
  • Adjust created user’s shadow password field from a locked form (!…) to an invalid-but-not-locked form (*) so OpenSSH 9.x accepts public-key auth.
  • Document the behavior change in the changelog.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
CHANGELOG Notes the Ubuntu 24.04 SSH login fix and its rationale.
base/etc/runit_init.d/02_user.sh Adds logic to remove conflicting default UID/GID entries and tweaks shadow password to avoid OpenSSH “locked account” behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +17 to +26
EXISTING_USER=$(getent passwd "$USER_ID" | cut -d: -f1)
if [ -n "$EXISTING_USER" ] && [ "$EXISTING_USER" != "$USER_NAME" ]; then
echo "Removing default user '$EXISTING_USER' occupying UID $USER_ID"
deluser "$EXISTING_USER" > /dev/null 2>&1 || userdel "$EXISTING_USER" > /dev/null 2>&1 || true
fi
EXISTING_GROUP=$(getent group "$USER_ID" | cut -d: -f1)
if [ -n "$EXISTING_GROUP" ] && [ "$EXISTING_GROUP" != "$USER_NAME" ]; then
echo "Removing default group '$EXISTING_GROUP' occupying GID $USER_ID"
groupdel "$EXISTING_GROUP" > /dev/null 2>&1 || true
fi
@skokec
skokec deleted the feat/ubuntu24-support branch June 17, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants