Browse Source

replace `passwd -u` to avoid empty passwords

https://github.com/fphammerle/docker-ssh-bastion/commit/245f093c25703f7433e2cf15b5c9654615e273fe
Fabian Peter Hammerle 4 years ago
parent
commit
74b7d04201
1 changed files with 6 additions and 1 deletions
  1. 6 1
      entrypoint.sh

+ 6 - 1
entrypoint.sh

@@ -14,7 +14,12 @@ IFS=','
 for USER in $USERS; do
     if ! id "$USER" 2>/dev/null >/dev/null ; then
         (set -x; adduser -D "$USER")
-        passwd -u "$USER" 2>/dev/null
+        # default after `adduser -D`: !
+        # > User alice not allowed because account is locked
+        # `passwd -u` sets an empty password,
+        # so better insert '*' manually
+        # https://unix.stackexchange.com/a/193131/155174
+        sed -i "s/^${USER}:!:/${USER}:*:/" /etc/shadow
     fi
 done