]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Save host SSH key fingerprints on kvmx-create
authorSilvio Rhatto <rhatto@riseup.net>
Wed, 13 Jun 2018 16:15:04 +0000 (13:15 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Wed, 13 Jun 2018 16:15:04 +0000 (13:15 -0300)
kvmx-create

index 3071346a295d7eebff01f2bfbd81c3d803113bf0..0982f4dcbb46bc1e2853813eae7fcc63c6d8701e 100755 (executable)
@@ -387,6 +387,16 @@ EOF
   # Fix hostname in keys
   kvmx_sudo_run sed -i -e "s/root@.*$/root@$hostname.$domain/" $WORK/etc/ssh/*.pub
 
+  # SSH dir
+  sshdir="`dirname $image`/ssh/"
+  mkdir -p $sshdir
+
+  # Save host SSH key fingerprints
+  for key in $WORK/etc/ssh/*pub; do
+    ssh-keygen -l        -f $key >> `basename $key`.sha256
+    ssh-keygen -l -E md5 -f $key >> `basename $key`.md5
+  done
+
   # Sudo
   echo "Installing sudo..."
   $APT_INSTALL sudo -y
@@ -402,9 +412,8 @@ EOF
 
   if [ "$ssh_support" == "y" ]; then
     if [ "$ssh_custom" == "y" ]; then
-      privkey="`dirname $image`/ssh/$hostname.key"
+      privkey="$sshdir/ssh/$hostname.key"
       pubkey="${privkey}.pub"
-      mkdir -p "`dirname $privkey`"
       __kvmx_ssh_keygen $privkey "$user@$hostname"
     else
       pubkey="$DIRNAME/share/ssh/insecure_private_key.pub"