Page MenuHomeFreeBSD

D52159.1789593627.diff
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

D52159.1789593627.diff

diff --git a/libexec/rc/rc.d/sshd b/libexec/rc/rc.d/sshd
--- a/libexec/rc/rc.d/sshd
+++ b/libexec/rc/rc.d/sshd
@@ -17,8 +17,9 @@
reload_precmd="sshd_configtest"
restart_precmd="sshd_configtest"
configtest_cmd="sshd_configtest"
+showfp_cmd="sshd_showfp"
pidfile="/var/run/${name}.pid"
-extra_commands="configtest keygen reload"
+extra_commands="configtest keygen reload showfp"
: ${sshd_rsa_enable:="yes"}
: ${sshd_ecdsa_enable:="yes"}
@@ -61,6 +62,37 @@
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|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"
}
@@ -77,10 +109,20 @@
eval ${command} ${sshd_flags} -t
}
+sshd_showfp()
+{
+ echo '-----BEGIN SSH HOST KEY FINGERPRINTS-----'
+ sshd_showfp_alg rsa
+ sshd_showfp_alg ecdsa
+ sshd_showfp_alg ed25519
+ echo '-----END SSH HOST KEY FINGERPRINTS-----'
+}
+
sshd_precmd()
{
run_rc_command keygen
run_rc_command configtest
+ run_rc_command showfp
}
load_rc_config $name

File Metadata

Mime Type
text/plain
Expires
Wed, Sep 16, 9:20 PM (8 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29706871
Default Alt Text
D52159.1789593627.diff (1 KB)

Event Timeline