better restart_sshd

This commit is contained in:
John Lancaster
2026-01-04 10:09:09 -06:00
parent 6705bab1fe
commit 0b1e8f5c08

View File

@@ -95,29 +95,41 @@ TrustedUserCAKeys /etc/ssh/ssh_user_ca.pub
HostKey /etc/ssh/ssh_host_ed25519_key
HostCertificate /etc/ssh/ssh_host_ed25519_key-cert.pub
EOF
echo -e "$GREEN_CHECK Configured sshd to use and accept SSH certs."
}
restart_sshd() {
if systemctl is-active --quiet sshd; then
local sshd_pid=$(systemctl show --property MainPID --value sshd)
kill -SIGHUP $sshd_pid
echo -e "$GREEN_CHECK Restarted sshd service on PID: $sshd_pid"
else
echo -e "$YELLOW_BANG Not running sshd service"
read -p "Do you want to start sshd? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
systemctl start sshd
echo -e "$GREEN_CHECK Started sshd"
fi
fi
}
#
# Run Process
#
if [[ ! -e "/etc/ssh/sshd_config.d/certs.conf" ]]; then
echo "⚠️ sshd not configured to use SSH certs"
echo -e "$YELLOW_BANG sshd not configured to use SSH certs"
read -p "Do you want to configure sshd? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
install_cert_config
echo -n "Restarting sshd..."
systemctl restart sshd
echo "done"
else
echo "Exiting"
exit 1
restart_sshd
fi
fi
check_ssh_files
echo ""