From 8c7ef328949503921b3b79d75c95dc4f80aec400 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Thu, 15 Feb 2024 18:03:16 +0900 Subject: [PATCH] Create user script update: allow no password, allow different password length --- Readme.md | 25 +++++++++++++++++++++++++ bin/create_user.sh | 10 ++++++++++ 2 files changed, 35 insertions(+) diff --git a/Readme.md b/Readme.md index 2515f62..410c9ee 100644 --- a/Readme.md +++ b/Readme.md @@ -26,6 +26,31 @@ Inside the base folder there are - ssh-keygen for temporary holding the PEM/PUB files - zip file which holds the created user list, password and PEM/PUB files +## Config + +### create_user.sh: create_user.cfg + +A `create_user.cfg` can be created to set a differen HOME_LOCATION and PASSWORD_LENGTH values + +eg: + +```ini +HOME_LOCATION="/storage" +PASSWORD_LENGTH=14 +``` + +### authorized_key_location_change.sh: authorized_key_location_change.ignore + +For this script a `authorized_key_location_change.ignore` with a list of user names to ignore for the +move + +eg: + +```ini +foo_user +bar_user +``` + ## Options ### -g (go) diff --git a/bin/create_user.sh b/bin/create_user.sh index 9046526..789e9a7 100755 --- a/bin/create_user.sh +++ b/bin/create_user.sh @@ -87,6 +87,12 @@ if [ ! -d "${HOME_FOLDER}" ]; then echo "Home folder location not found: ${HOME_FOLDER}"; error=1; fi; +# allow 10 to 39 length for password +if ! [[ "${PASSWORD_LENGTH}" =~ ^[13][0-9]$ ]] || [ -z ${PASSWORD_LENGTH} ]; then + echo "Password length set error, can only be a value between 10 and 39"; + error=1; +fi; +error=1; # home dir error abort if [ $error -eq 1 ]; then exit; @@ -310,6 +316,10 @@ while read i; do # password + store pwgen 10 1 -1 if [ -z "${_password}" ]; then password=$(printf "%s" $(pwgen 14 1)); + elif [ "${_password}" = "SET_NO_PASSWORD" ]; then + # set empty + echo "* No password set"; + password=""; else echo "! Override password set"; password=${_password};