diff --git a/scripts/ssh-server-check.sh b/scripts/ssh-server-check.sh index 5a7e87e..ed621fa 100755 --- a/scripts/ssh-server-check.sh +++ b/scripts/ssh-server-check.sh @@ -35,17 +35,20 @@ ssh_config_val() { prompt_user() { local title="\e[1m${1:-Title}\e[0m" local prompt="${2:-Prompt for the user}" - local msg="$title: $prompt" + full_prompt_msg="$title: $prompt" - echo -n -e "$YELLOW_BANG $msg" + echo -n -e "$YELLOW_BANG $full_prompt_msg" read -p " (y/n) " -n 1 -r echo +} - update_prompt() { - echo -en "\e[1A\r\e[K" - echo -e "$1 $msg $REPLY" - } +update_prompt() { + local msg="${1:-$full_prompt_msg}" + echo -en "\e[1A\r\e[K" + echo -e "$1 $msg $REPLY" +} +auto_update_prompt() { if [[ $REPLY =~ ^[Yy]$ ]]; then update_prompt $GREEN_CHECK elif [[ $REPLY =~ ^[Nn]$ ]]; then @@ -53,7 +56,6 @@ prompt_user() { fi } - sign_host_cert() { local if="eth0" local IP_ADDRESS=$(ip -4 addr show dev $if | awk '/inet /{print $2}' | cut -d/ -f1) && \ @@ -118,12 +120,11 @@ check_ssh_files() { missing) # Do something if trustedusercakeys is missing prompt_user "User CA" "Created the trusted keys file?" - - # read -p "Create the trusted keys file? (y/n) " -n 1 -r - # echo if [[ $REPLY =~ ^[Yy]$ ]]; then (step ssh config --roots > "$path") - echo -e "$GREEN_CHECK Created public key file for SSH user CA" + update_prompt $GREEN_CHECK "Created public key file for SSH user CA" + else + update_prompt $RED_X fi ;; unconfigured) return;; @@ -159,14 +160,11 @@ check_cert_config() { install_cert_config() { mkdir -p $(dirname $cfg_path) - cat < $cfg_path TrustedUserCAKeys $SSH_USER_CA HostKey $SSH_HOST_KEY HostCertificate $SSH_HOST_CERT EOF - - echo -e "$GREEN_CHECK Configured sshd to use and accept SSH certs." } if [[ ! -e $cfg_path ]]; then