Create user script update: allow no password, allow different password length

This commit is contained in:
Clemens Schwaighofer
2024-02-15 18:03:16 +09:00
parent 70ef7a3fc5
commit 8c7ef32894
2 changed files with 35 additions and 0 deletions

View File

@@ -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)

View File

@@ -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};