Compare commits
2 Commits
a26c71c092
...
6886b6ca69
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6886b6ca69 | ||
|
|
42b3506b1c |
@@ -33,7 +33,7 @@ check_ssh_files() {
|
||||
printf "%-17b %-20s %-6s %s\n" " $GREEN_CHECK" "$key" "$perms" "$path"
|
||||
}
|
||||
|
||||
row_fail() {
|
||||
row_missing() {
|
||||
local key="$1"
|
||||
local path="$2"
|
||||
printf "%-15b %-20s %-6s %s\n" " $YELLOW_BANG" "$key" "-" "$path (missing)"
|
||||
@@ -44,32 +44,47 @@ 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 <key>" >&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"
|
||||
path=$(ssh_config_val "$key")
|
||||
status=$(get_key_status "$path")
|
||||
case "$status" in
|
||||
success) row_success "$key" "$path" ;;
|
||||
missing) row_missing "$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"
|
||||
case "$status" in
|
||||
success) return ;;
|
||||
missing)
|
||||
# Do something if trustedusercakeys is missing
|
||||
read -p "Create the trusted keys file? (y/n) " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
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() {
|
||||
|
||||
Reference in New Issue
Block a user