This commit is contained in:
John Lancaster
2026-01-04 16:50:46 -06:00
parent fe0c66d57a
commit c020c481cf

View File

@@ -19,6 +19,7 @@ CREATE_USER_CA=0
CREATE_HOST_CERT=0 CREATE_HOST_CERT=0
NEEDS_RESTART=0 NEEDS_RESTART=0
# #
# Function Definitions # Function Definitions
# #
@@ -39,7 +40,8 @@ ssh_config_val() {
title_msg() { title_msg() {
local title="\e[1m${1:-Title}:\e[0m" local title="\e[1m${1:-Title}:\e[0m"
local prompt="${2:-Prompt for the user}" local prompt="${2:-Prompt for the user}"
printf "%b %b" "$title" "$prompt" # printf "%b %b" "$title" "$prompt"
echo -e "$title $prompt"
} }
prompt_user() { prompt_user() {
@@ -186,13 +188,11 @@ restart_sshd() {
update_prompt $RED_X "sshd" "Failed to restart sshd.service" update_prompt $RED_X "sshd" "Failed to restart sshd.service"
exit 1 exit 1
fi fi
echo
} }
create_files() { create_files() {
local wrote_lines=0
if [[ $CREATE_HOST_CERT -eq 1 ]]; then if [[ $CREATE_HOST_CERT -eq 1 ]]; then
wrote_lines=1
prompt_user "SSH Host" "Cert missing. Sign the ssh host cert?" prompt_user "SSH Host" "Cert missing. Sign the ssh host cert?"
if [[ $REPLY =~ ^[Yy]$ ]]; then if [[ $REPLY =~ ^[Yy]$ ]]; then
update_prompt $YELLOW_BANG "Signing ssh host cert" update_prompt $YELLOW_BANG "Signing ssh host cert"
@@ -204,7 +204,6 @@ create_files() {
fi fi
if [[ $CREATE_USER_CA -eq 1 ]]; then if [[ $CREATE_USER_CA -eq 1 ]]; then
wrote_lines=1
prompt_user "SSH Host" "Create the trusted keys file?" prompt_user "SSH Host" "Create the trusted keys file?"
if [[ $REPLY =~ ^[Yy]$ ]]; then if [[ $REPLY =~ ^[Yy]$ ]]; then
(step ssh config --roots > "$path") (step ssh config --roots > "$path")
@@ -214,8 +213,6 @@ create_files() {
update_prompt $RED_X update_prompt $RED_X
fi fi
fi fi
if [[ $wrote_lines -eq 1 ]]; then echo; fi
} }
@@ -226,7 +223,7 @@ check_ssh_config_files
create_files create_files
restart_sshd restart_sshd
title_msg "SSH Host Cert" "$SSH_HOST_CERT\n" title_msg "SSH Host Cert" "$SSH_HOST_CERT"
CERT_INFO=$(ssh-keygen -Lf "$SSH_HOST_CERT") CERT_INFO=$(ssh-keygen -Lf "$SSH_HOST_CERT")
echo -e "$CERT_INFO" | grep "Public key" echo -e "$CERT_INFO" | grep "Public key"
echo -e "$CERT_INFO" | grep "Valid" echo -e "$CERT_INFO" | grep "Valid"