updating prompt
This commit is contained in:
@@ -1,20 +1,24 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
GREEN_CHECK="\e[32m✔\e[0m"
|
#
|
||||||
RED_X="\e[31m✗\e[0m"
|
# Env vars
|
||||||
YELLOW_BANG="\e[33m!\e[0m"
|
#
|
||||||
|
|
||||||
|
# SSH config paths
|
||||||
SSH_CFG_DIR="/etc/ssh"
|
SSH_CFG_DIR="/etc/ssh"
|
||||||
SSH_USER_CA="$SSH_CFG_DIR/ssh_user_ca.pub"
|
SSH_USER_CA="$SSH_CFG_DIR/ssh_user_ca.pub"
|
||||||
SSH_HOST_KEY="$SSH_CFG_DIR/ssh_host_ed25519_key"
|
SSH_HOST_KEY="$SSH_CFG_DIR/ssh_host_ed25519_key"
|
||||||
SSH_HOST_PUBLIC_KEY="$SSH_HOST_KEY.pub"
|
SSH_HOST_PUBLIC_KEY="$SSH_HOST_KEY.pub"
|
||||||
SSH_HOST_CERT="$SSH_HOST_KEY-cert.pub"
|
SSH_HOST_CERT="$SSH_HOST_KEY-cert.pub"
|
||||||
|
|
||||||
|
GREEN_CHECK="\e[32m✔\e[0m"
|
||||||
|
RED_X="\e[31m✗\e[0m"
|
||||||
|
YELLOW_BANG="\e[33m!\e[0m"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Function Definition
|
# Function Definition
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
# This test loads the sshd config to see what values actually get parsed.
|
# This test loads the sshd config to see what values actually get parsed.
|
||||||
ssh_config_val() {
|
ssh_config_val() {
|
||||||
local field="$1"
|
local field="$1"
|
||||||
@@ -28,6 +32,27 @@ ssh_config_val() {
|
|||||||
echo $(sshd -T 2>/dev/null | grep -i "^$field " | head -1 | awk '{print $2}')
|
echo $(sshd -T 2>/dev/null | grep -i "^$field " | head -1 | awk '{print $2}')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prompt_user() {
|
||||||
|
local title="\e[1m${1:-Title}\e[0m"
|
||||||
|
local prompt="${2:-Prompt for the user}"
|
||||||
|
local msg="$title: $prompt"
|
||||||
|
|
||||||
|
echo -n -e "$YELLOW_BANG $msg"
|
||||||
|
read -p " (y/n) " -n 1 -r
|
||||||
|
echo
|
||||||
|
|
||||||
|
update_prompt() {
|
||||||
|
echo -en "\e[1A\r\e[K"
|
||||||
|
echo -e "$1 $msg $REPLY"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
|
update_prompt $GREEN_CHECK
|
||||||
|
elif [[ $REPLY =~ ^[Nn]$ ]]; then
|
||||||
|
update_prompt $RED_X
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sign_host_cert() {
|
sign_host_cert() {
|
||||||
local if="eth0"
|
local if="eth0"
|
||||||
@@ -92,8 +117,10 @@ check_ssh_files() {
|
|||||||
success) return ;;
|
success) return ;;
|
||||||
missing)
|
missing)
|
||||||
# Do something if trustedusercakeys is missing
|
# Do something if trustedusercakeys is missing
|
||||||
read -p "Create the trusted keys file? (y/n) " -n 1 -r
|
prompt_user "User CA" "Created the trusted keys file?"
|
||||||
echo
|
|
||||||
|
# read -p "Create the trusted keys file? (y/n) " -n 1 -r
|
||||||
|
# echo
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
(step ssh config --roots > "$path")
|
(step ssh config --roots > "$path")
|
||||||
echo -e "$GREEN_CHECK Created public key file for SSH user CA"
|
echo -e "$GREEN_CHECK Created public key file for SSH user CA"
|
||||||
@@ -144,9 +171,7 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
if [[ ! -e $cfg_path ]]; then
|
if [[ ! -e $cfg_path ]]; then
|
||||||
echo -e "$YELLOW_BANG sshd not configured to use SSH certs"
|
prompt_user "sshd config" "Do you want to configure sshd?"
|
||||||
read -p "Do you want to configure sshd? (y/n) " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
install_cert_config
|
install_cert_config
|
||||||
restart_sshd
|
restart_sshd
|
||||||
@@ -175,9 +200,12 @@ restart_sshd() {
|
|||||||
# Run Process
|
# Run Process
|
||||||
#
|
#
|
||||||
|
|
||||||
check_cert_config "certs.conf"
|
# check_cert_config "certs.conf"
|
||||||
check_ssh_files
|
# check_ssh_files
|
||||||
|
|
||||||
echo ""
|
# echo ""
|
||||||
echo "Host key fingerprint"
|
# echo "Host key fingerprint"
|
||||||
ssh_fingerprint hostkey
|
# ssh_fingerprint hostkey
|
||||||
|
|
||||||
|
|
||||||
|
prompt_user
|
||||||
Reference in New Issue
Block a user