Skip to content

Commit 73f0789

Browse files
committed
Fix unlocking
1 parent 68de006 commit 73f0789

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/rootfs/usr/local/bin/serversideup-create-unprivileged-user

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,20 @@ PGID="$3"
2525
if [ -f /etc/alpine-release ]; then
2626
# Alpine
2727
addgroup -g "${PGID}" "${username}" && \
28-
adduser -u "${PUID}" -G "${username}" -h "/home/${username}" -s /bin/sh -D "${username}" && \
29-
# Set account to expired but not locked
30-
chage -E 0 "${username}"
28+
adduser -u "${PUID}" -G "${username}" -h "/home/${username}" -s /bin/sh -D "${username}"
3129
else
3230
# Debian
33-
addgroup --gid "${PGID}" "${username}" && \
34-
adduser --uid "${PUID}" \
35-
--gid "${PGID}" \
36-
--home "/home/${username}" \
37-
--shell /bin/bash \
38-
--disabled-password \
39-
--gecos '' \
40-
"${username}" && \
41-
# Set a locked password that can't be used but keeps the account unlocked
42-
usermod -p '!' "${username}"
43-
fi
31+
groupadd -g "${PGID}" "${username}" && \
32+
useradd --no-log-init \
33+
-m \
34+
-s /bin/bash \
35+
-d "/home/${username}" \
36+
-u "${PUID}" \
37+
-g "${PGID}" \
38+
"${username}"
39+
fi
40+
41+
# Set a proper password hash that allows SSH key auth but prevents password login
42+
# '*' allows the account to be active but prevents password login
43+
# This works the same way on both Alpine and Debian
44+
usermod -p '*' "${username}"

0 commit comments

Comments
 (0)