From: Silvio Rhatto Date: Wed, 13 Jun 2018 16:29:58 +0000 (-0300) Subject: Adds ssh_finger action X-Git-Tag: 0.1.0~245 X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=a428e7115bb66e58c8db1039cd9659491dd940a9;p=kvmx.git Adds ssh_finger action --- diff --git a/kvmx b/kvmx index 1d1eef8..826c223 100755 --- a/kvmx +++ b/kvmx @@ -647,6 +647,40 @@ function kvmx_ssh { $ssh_env $SSH_COMMAND -p $SSH 127.0.0.1 $* } +# Get guest SSH key fingerprints +function kvmx_ssh_finger { + if ls $DATADIR/ssh/*.pub.* &> /dev/null; then + for finger in $DATADIR/ssh/*.pub.*; do + cat $finger + done + else + # Try to get list of keys in the server + keys="$( + echo | kvmx_ssh << EOF + for key in /etc/ssh/*pub; do + echo \$key + #ssh-keygen -l -f \$key + #ssh-keygen -l -E md5 -f \$key + done +EOF +)" + + # Get fingerprint for each key + if [ ! -z "$keys" ]; then + for key in $keys; do + fingerprint="$(echo ssh-keygen -l -f $key | kvmx_ssh)" + echo $fingerprint | tee $DATADIR/ssh/`basename $key`.sha256 + + fingerprint="$(echo ssh-keygen -l -E md5 -f $key | kvmx_ssh)" + echo $fingerprint | tee $DATADIR/ssh/`basename $key`.md5 + done + else + echo "$BASENAME: could not get SSH fingerprints for $VM" + exit 1 + fi + fi +} + # Suspend the virtual machine function kvmx_suspend { if ! kvmx_running; then