From 5aece92a4143aaad0992dc67ab48f5b24d460e0c Mon Sep 17 00:00:00 2001 From: Aleksandr Berkuta Date: Mon, 19 May 2025 17:43:19 +0300 Subject: [PATCH] Add passwd_hash Without password hash '$user:*' to `chpasswd -e` will result to inability for user to login, or change password. So I've add parameter passwd_hash for the user. Password hash could be generated via command `openssl passwd -5 your_password`. --- lib/tiny-cloud/user-data/cloud-config | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/tiny-cloud/user-data/cloud-config b/lib/tiny-cloud/user-data/cloud-config index c389b90..8406ac4 100644 --- a/lib/tiny-cloud/user-data/cloud-config +++ b/lib/tiny-cloud/user-data/cloud-config @@ -286,12 +286,16 @@ init__userdata_users() { $MOCK adduser -D ${gecos:+-g "$gecos"} ${homedir:+-h "$homedir"} ${shell:+-s "$shell"} ${primary_group:+-G "$primary_group"} ${system:+-S} ${no_create_home:+-H} "$name" fi + if in_list hashed_passwd $keys; then + hashed_passwd="$(get_userdata users/$i/hashed_passwd)" + fi + if in_list lock_passwd $keys; then lock_passwd="$(get_userdata users/$i/lock_passwd)" fi if [ "$lock_passwd" != "false" ]; then - echo "$name:*" | $MOCK chpasswd -e + echo "${name}:${hashed_passwd}" | $MOCK chpasswd -e fi if in_list ssh_authorized_keys $keys; then @@ -314,7 +318,7 @@ init__userdata_users() { for j in $(get_userdata users/$i/doas); do local line="$(get_userdata users/$i/doas/$j)" if [ -d "$ETC/doas.d" ]; then - echo "$line" >> "$ETC/doas.d/$name.conf" + echo "$line" >>"$ETC/doas.d/$name.conf" elif [ -f "$ETC/doas.conf" ]; then add_once "$ETC/doas.conf" "$line" fi