From 87d53cdb13625c848883aa6ed806f5bef7ec5337 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Fri, 2 Dec 2022 09:59:39 +0900 Subject: [PATCH] Create user bug with positions in list file --- bin/create_user.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bin/create_user.sh b/bin/create_user.sh index 343097c..85a87ff 100755 --- a/bin/create_user.sh +++ b/bin/create_user.sh @@ -109,11 +109,13 @@ while read i; do if [[ "${i}" =~ ^\# ]]; then continue; fi; - # make lower case, remove spaces + # POS 2: make lower case, remove spaces username=$(echo "${i}" | cut -d ";" -f 2 | tr A-Z a-z | tr -d ' '); + # POS 3: groups _group=$(echo "${i}" | cut -d ";" -f 3 | tr A-Z a-z | tr -d ' '); group=$(echo "${_group}" | cut -d "," -f 1); sub_group=""; + # POS 4: ssh access type ssh_access_type=$(echo "${i}" | cut -d ";" -f 4 | tr A-Z a-z | tr -d ' '); # if not allow or forward, set to access if [ "${ssh_access_type}" != "allow" ] && [ "${ssh_access_type}" != "forward" ]; then @@ -132,16 +134,17 @@ while read i; do sub_group=$(echo "${_group}" | cut -d "," -f 2-); sub_group_opt=" -G ${sub_group}"; fi; - # override host name, lowercase and spaces removed - _hostname=$(echo "${i}" | cut -d ";" -f 5 | tr A-Z a-z | tr -d ' '); + # POS 5: do we have a password preset + _password=$(echo "${i}" | cut -d ";" -f 5); + # POS 6: override host name, lowercase and spaces removed + _hostname=$(echo "${i}" | cut -d ";" -f 6 | tr A-Z a-z | tr -d ' '); if [ -z "${_hostname}" ]; then hostname=${host}; else hostname=${_hostname}; fi; - # do we have a password preset - _password=$(echo "${i}" | cut -d ";" -f 4); - _ssh_keytype=$(echo "${i}" | cut -d ";" -f 6 | tr A-Z a-z | tr -d ' '); + # POS 7: ssh keytype override + _ssh_keytype=$(echo "${i}" | cut -d ";" -f 7 | tr A-Z a-z | tr -d ' '); if [ "${_ssh_keytype}" = "rsa" ]; then ssh_keytype="${_ssh_keytype}"; #echo "[!!] BACKWARDS COMPATIBLE RSA TYPE SELECTION [!!]";