more case structure
This commit is contained in:
@@ -33,7 +33,7 @@ check_ssh_files() {
|
|||||||
printf "%-17b %-20s %-6s %s\n" " $GREEN_CHECK" "$key" "$perms" "$path"
|
printf "%-17b %-20s %-6s %s\n" " $GREEN_CHECK" "$key" "$perms" "$path"
|
||||||
}
|
}
|
||||||
|
|
||||||
row_fail() {
|
row_missing() {
|
||||||
local key="$1"
|
local key="$1"
|
||||||
local path="$2"
|
local path="$2"
|
||||||
printf "%-15b %-20s %-6s %s\n" " $YELLOW_BANG" "$key" "-" "$path (missing)"
|
printf "%-15b %-20s %-6s %s\n" " $YELLOW_BANG" "$key" "-" "$path (missing)"
|
||||||
@@ -57,28 +57,34 @@ check_ssh_files() {
|
|||||||
|
|
||||||
row_process() {
|
row_process() {
|
||||||
local key="$1"
|
local key="$1"
|
||||||
local path=$(ssh_config_val "$key")
|
path=$(ssh_config_val "$key")
|
||||||
local status=$(get_key_status "$path")
|
status=$(get_key_status "$path")
|
||||||
case "$status" in
|
case "$status" in
|
||||||
success) row_success "$key" "$path" ;;
|
success) row_success "$key" "$path" ;;
|
||||||
missing) row_fail "$key" "$path" ;;
|
missing) row_missing "$key" "$path" ;;
|
||||||
unconfigured) row_unconfigured "$key" ;;
|
unconfigured) row_unconfigured "$key" ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
printf "%-6s %-20s %-6s %s\n" "STATUS" "KEY" "PERMS" "PATH"
|
printf "%-6s %-20s %-6s %s\n" "STATUS" "KEY" "PERMS" "PATH"
|
||||||
|
|
||||||
# hostkey
|
row_process "hostkey"
|
||||||
key="hostkey"
|
row_process "hostcertificate"
|
||||||
row_process $key
|
row_process "trustedusercakeys"
|
||||||
|
case "$status" in
|
||||||
# hostcertificate
|
success) return ;;
|
||||||
key="hostcertificate"
|
missing)
|
||||||
row_process $key
|
# Do something if trustedusercakeys is missing
|
||||||
|
read -p "Create the trusted keys file? (y/n) " -n 1 -r
|
||||||
# trustedusercakeys
|
echo
|
||||||
key="trustedusercakeys"
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
row_process $key
|
echo "Creating public key file at $path"
|
||||||
|
(step ssh config --roots > "$path")
|
||||||
|
echo -e "$GREEN_CHECK Created public key file for SSH user CA"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
unconfigured) return;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
ssh_fingerprint() {
|
ssh_fingerprint() {
|
||||||
|
|||||||
Reference in New Issue
Block a user