prompts wip
This commit is contained in:
@@ -35,17 +35,20 @@ ssh_config_val() {
|
|||||||
prompt_user() {
|
prompt_user() {
|
||||||
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}"
|
||||||
local msg="$title: $prompt"
|
full_prompt_msg="$title: $prompt"
|
||||||
|
|
||||||
echo -n -e "$YELLOW_BANG $msg"
|
echo -n -e "$YELLOW_BANG $full_prompt_msg"
|
||||||
read -p " (y/n) " -n 1 -r
|
read -p " (y/n) " -n 1 -r
|
||||||
echo
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
update_prompt() {
|
update_prompt() {
|
||||||
|
local msg="${1:-$full_prompt_msg}"
|
||||||
echo -en "\e[1A\r\e[K"
|
echo -en "\e[1A\r\e[K"
|
||||||
echo -e "$1 $msg $REPLY"
|
echo -e "$1 $msg $REPLY"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto_update_prompt() {
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
update_prompt $GREEN_CHECK
|
update_prompt $GREEN_CHECK
|
||||||
elif [[ $REPLY =~ ^[Nn]$ ]]; then
|
elif [[ $REPLY =~ ^[Nn]$ ]]; then
|
||||||
@@ -53,7 +56,6 @@ prompt_user() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sign_host_cert() {
|
sign_host_cert() {
|
||||||
local if="eth0"
|
local if="eth0"
|
||||||
local IP_ADDRESS=$(ip -4 addr show dev $if | awk '/inet /{print $2}' | cut -d/ -f1) && \
|
local IP_ADDRESS=$(ip -4 addr show dev $if | awk '/inet /{print $2}' | cut -d/ -f1) && \
|
||||||
@@ -118,12 +120,11 @@ check_ssh_files() {
|
|||||||
missing)
|
missing)
|
||||||
# Do something if trustedusercakeys is missing
|
# Do something if trustedusercakeys is missing
|
||||||
prompt_user "User CA" "Created the trusted keys file?"
|
prompt_user "User CA" "Created the trusted keys file?"
|
||||||
|
|
||||||
# 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"
|
update_prompt $GREEN_CHECK "Created public key file for SSH user CA"
|
||||||
|
else
|
||||||
|
update_prompt $RED_X
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
unconfigured) return;;
|
unconfigured) return;;
|
||||||
@@ -159,14 +160,11 @@ check_cert_config() {
|
|||||||
|
|
||||||
install_cert_config() {
|
install_cert_config() {
|
||||||
mkdir -p $(dirname $cfg_path)
|
mkdir -p $(dirname $cfg_path)
|
||||||
|
|
||||||
cat <<EOF > $cfg_path
|
cat <<EOF > $cfg_path
|
||||||
TrustedUserCAKeys $SSH_USER_CA
|
TrustedUserCAKeys $SSH_USER_CA
|
||||||
HostKey $SSH_HOST_KEY
|
HostKey $SSH_HOST_KEY
|
||||||
HostCertificate $SSH_HOST_CERT
|
HostCertificate $SSH_HOST_CERT
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo -e "$GREEN_CHECK Configured sshd to use and accept SSH certs."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ ! -e $cfg_path ]]; then
|
if [[ ! -e $cfg_path ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user