Display SSH server key fingerprints
authorMichael Prokop <mika@grml.org>
Tue, 25 Sep 2012 14:53:53 +0000 (16:53 +0200)
committerMichael Prokop <mika@grml.org>
Tue, 25 Sep 2012 15:07:16 +0000 (17:07 +0200)
Useful if using the ssh boot option or providing your own
configuration files/script shipping SSH server keys.

Thanks: Peter Palfrader for the idea

autoconfig
autoconfig.functions
grml-autoconfig

index dce5adb..ada7c18 100644 (file)
@@ -57,6 +57,7 @@ CONFIG_DEBOOTSTRAP='yes'      # support automatic installation of Debian via grm
 CONFIG_DEBNET='yes'           # search for /etc/network/interfaces on partitions and set up network afterwards
 CONFIG_DEBS='yes'             # check for bootoption debs for installing .debs
 CONFIG_DEBUG='yes'            # activate start of shells during startup at several stages
+CONFIG_DISPLAY_SSH_FINGERPRINTS='yes' # display SSH server key fingerprints
 CONFIG_DISTCC='yes'           # activate and setup distcc through bootparam distcc=$NETWORK,$INTERFACE
 CONFIG_DISTRI='yes'           # support some customization via bootoption distri
 CONFIG_DMA='yes'              # Enable DMA for all IDE drives
index 9488f55..06265e8 100755 (executable)
@@ -1121,6 +1121,22 @@ if checkbootparam 'ssh' ; then
    eoutdent
 fi
 }
+
+# }}}
+
+# {{{ display hostkeys of SSH server
+config_display_ssh_fingerprints() {
+  if ! find /etc/ssh/ -name ssh_host_\*_key >/dev/null 2>&1 ; then
+    return 0 # no SSH host keys present
+  fi
+
+  einfo "SSH key fingerprints:"
+  for file in /etc/ssh/ssh_host_*_key ; do
+    einfon
+    ssh-keygen -l -f $file
+  done | column -t
+  eend $?
+}
 # }}}
 
 # {{{ autostart of x11vnc
@@ -1473,6 +1489,7 @@ config_stats() {
  fi
 }
 # }}}
+
 # {{{ fix/workaround for unionfs
 fix_unionfs(){
   if [ -z "$INSTALLED" ]; then
index a5a800d..9305cfe 100755 (executable)
@@ -164,6 +164,8 @@ checkvalue $CONFIG_SERVICES && config_services
 
 checkvalue $CONFIG_DEBNET && config_debnet
 
+checkvalue $CONFIG_DISPLAY_SSH_FINGERPRINTS && config_display_ssh_fingerprints
+
 checkvalue $CONFIG_NETCONFIG && config_netconfig
 
 checkvalue $CONFIG_NETSCRIPT && config_netscript