diff --git a/scripts/ssh-server-check.sh b/scripts/ssh-server-check.sh index b535e87..2e59772 100755 --- a/scripts/ssh-server-check.sh +++ b/scripts/ssh-server-check.sh @@ -44,32 +44,41 @@ check_ssh_files() { printf "%-17b %-20s %-6s %s\n" " $RED_X" "$key" "-" "(not configured)" } - row_process() { - local key="$1" - - if [[ -z "$key" ]]; then - echo "usage: row_process " >&2 - return 2 - fi - - path=$(ssh_config_val "$key") - + get_key_status() { + local path="$1" if [[ -z "$path" ]]; then - row_unconfigured $key - continue - fi - - if [[ -e "$path" ]]; then - row_success $key $path + echo "unconfigured" + elif [[ ! -e "$path" ]]; then + echo "missing" else - row_fail $key $path + echo "success" fi } + row_process() { + local key="$1" + local path=$(ssh_config_val "$key") + local status=$(get_key_status "$path") + case "$status" in + success) row_success "$key" "$path" ;; + missing) row_fail "$key" "$path" ;; + unconfigured) row_unconfigured "$key" ;; + esac + } + printf "%-6s %-20s %-6s %s\n" "STATUS" "KEY" "PERMS" "PATH" - row_process "hostkey" - row_process "hostcertificate" - row_process "trustedusercakeys" + + # hostkey + key="hostkey" + row_process $key + + # hostcertificate + key="hostcertificate" + row_process $key + + # trustedusercakeys + key="trustedusercakeys" + row_process $key } ssh_fingerprint() {