From fb00036ab91def55cbcc701907ed52f24c5825b1 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Tue, 31 Jan 2023 13:29:00 +0900 Subject: [PATCH] Abort on invalid option, always set ssh keytype so it doesn't stay on last selected --- bin/create_user.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/create_user.sh b/bin/create_user.sh index 5603c35..2742a48 100755 --- a/bin/create_user.sh +++ b/bin/create_user.sh @@ -35,6 +35,11 @@ while getopts ":ti" opt; do i|info) INFO=1; ;; + \?) + echo -e "\n Option does not exist: ${OPTARG}\n"; + echo "Use -t for test and -i for info"; + exit 1; + ;; esac; done; # hostname for output file only @@ -52,7 +57,9 @@ output_zip_folder='zip/'; output_zip="users.${timestamp}.zip" ssh_keygen_folder='ssh-keygen/'; ssh_keygen_folder_created_pub='ssh-keygen-created-pub/'; -ssh_keytype='ed25519'; +# set default key tpye +default_ssh_keytype='ed25519'; +ssh_keytype=''; # sshallow or sshforward ssh_group=''; ssh_forward_ok=0; @@ -148,6 +155,8 @@ while read i; do if [ "${_ssh_keytype}" = "rsa" ]; then ssh_keytype="${_ssh_keytype}"; #echo "[!!] BACKWARDS COMPATIBLE RSA TYPE SELECTION [!!]"; + else + ssh_keytype=${default_ssh_keytype}; fi; # user & group not set if [ -z "${username}" ] || [ -z "${_group}" ]; then