diff --git a/README.md b/README.md index 3084ca8..8baef7a 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ bash setup.sh ``` # Setup prompts -When the setup script is run, you will be prompted to enter the username and password of the new user account. +When the setup script is run, you will be prompted to enter the username of the new user account. Following that, you will then be prompted to add a public ssh key (which should be from your local machine) for the new account. To generate an ssh key from your local machine: ```bash diff --git a/setup.sh b/setup.sh index 84af15c..8971fea 100644 --- a/setup.sh +++ b/setup.sh @@ -20,12 +20,10 @@ output_file="output.log" function main() { read -rp "Enter the username of the new user account:" username - promptForPassword - # Run setup functions trap cleanup EXIT SIGHUP SIGINT SIGTERM - addUserAccount "${username}" "${password}" + addUserAccount "${username}" read -rp $'Paste in the public SSH key for the new user:\n' sshKey echo 'Running setup script...' @@ -89,21 +87,4 @@ function setupTimezone() { echo "Timezone is set to $(cat /etc/timezone)" >&3 } -# Keep prompting for the password and password confirmation -function promptForPassword() { - PASSWORDS_MATCH=0 - while [ "${PASSWORDS_MATCH}" -eq "0" ]; do - read -s -rp "Enter new UNIX password:" password - printf "\n" - read -s -rp "Retype new UNIX password:" password_confirmation - printf "\n" - - if [[ "${password}" != "${password_confirmation}" ]]; then - echo "Passwords do not match! Please try again." - else - PASSWORDS_MATCH=1 - fi - done -} - main \ No newline at end of file diff --git a/setupLibrary.sh b/setupLibrary.sh index 68026ee..ec03e33 100644 --- a/setupLibrary.sh +++ b/setupLibrary.sh @@ -3,12 +3,10 @@ # Add the new user account # Arguments: # Account Username -# Account Password # Flag to determine if user account is added silently. (With / Without GECOS prompt) function addUserAccount() { local username=${1} - local password=${2} - local silent_mode=${3} + local silent_mode=${2} if [[ ${silent_mode} == "true" ]]; then sudo adduser --disabled-password --gecos '' "${username}" @@ -16,8 +14,8 @@ function addUserAccount() { sudo adduser --disabled-password "${username}" fi - echo "${username}:${password}" | sudo chpasswd sudo usermod -aG sudo "${username}" + sudo passwd -d "${username}" } # Add the local machine public SSH Key for the new user account diff --git a/tests/unit-tests.sh b/tests/unit-tests.sh index 1ec6776..c4b0e50 100644 --- a/tests/unit-tests.sh +++ b/tests/unit-tests.sh @@ -23,7 +23,6 @@ source "${current_dir}/lib/bunit.shl" source "${current_dir}/../setupLibrary.sh" test_user_account=testuser -test_account_password="123%pass_321" # shellcheck disable=SC2034 VERBOSE_MODE="true" @@ -32,7 +31,7 @@ VERBOSE_MODE="true" function testSetup () { echo "Test Setup" - addUserAccount ${test_user_account} ${test_account_password} true + addUserAccount ${test_user_account} true } function testUserAccountCreated() {