Created
May 16, 2024 07:50
-
-
Save lwhsu/aa042311d3924d62b40cce455aadccd6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/libexec/rc/rc.d/sshd b/libexec/rc/rc.d/sshd | |
index 63113fd9ee74..faf619a6639c 100755 | |
--- a/libexec/rc/rc.d/sshd | |
+++ b/libexec/rc/rc.d/sshd | |
@@ -56,6 +56,37 @@ sshd_keygen_alg() | |
echo "Generating $ALG host key." | |
/usr/bin/ssh-keygen -q -t $alg -f "$keyfile" -N "" | |
+} | |
+ | |
+sshd_showfp_alg() | |
+{ | |
+ local alg=$1 | |
+ local ALG="$(echo $alg | tr a-z A-Z)" | |
+ local keyfile | |
+ | |
+ if ! checkyesno "sshd_${alg}_enable" ; then | |
+ return 0 | |
+ fi | |
+ | |
+ case $alg in | |
+ rsa|dsa|ecdsa|ed25519) | |
+ keyfile="/etc/ssh/ssh_host_${alg}_key" | |
+ ;; | |
+ *) | |
+ return 1 | |
+ ;; | |
+ esac | |
+ | |
+ if [ ! -f "${keyfile}" ] ; then | |
+ warn "$ALG host key does not exist." | |
+ return 1 | |
+ fi | |
+ | |
+ if [ ! -x /usr/bin/ssh-keygen ] ; then | |
+ warn "/usr/bin/ssh-keygen does not exist." | |
+ return 1 | |
+ fi | |
+ | |
/usr/bin/ssh-keygen -l -f "$keyfile.pub" | |
} | |
@@ -73,10 +104,19 @@ sshd_configtest() | |
eval ${command} ${sshd_flags} -t | |
} | |
+sshd_showfp() | |
+{ | |
+ sshd_showfp_alg rsa | |
+ sshd_showfp_alg dsa | |
+ sshd_showfp_alg ecdsa | |
+ sshd_showfp_alg ed25519 | |
+} | |
+ | |
sshd_precmd() | |
{ | |
run_rc_command keygen | |
run_rc_command configtest | |
+ run_rc_command showfp | |
} | |
load_rc_config $name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment