Repository navigation
Fix SSH logins into containers on Ubuntu 24.04 - #11
Merged
Merged
Conversation
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
There was a problem hiding this comment.
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
1000on 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two Noble-specific regressions broke
Permission denied (publickey):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; underset -ethe 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.adduser --disabled-passwordleaves 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