diff options
-rwxr-xr-x | kvmx | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -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 |