diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2018-06-13 13:29:58 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2018-06-13 13:29:58 -0300 |
commit | a428e7115bb66e58c8db1039cd9659491dd940a9 (patch) | |
tree | ee3c7eae5f7cbb5643fc99fa0fbb4bf3de350776 | |
parent | 80d7be771c6e442e46c74bedb71207fdf6400fa6 (diff) | |
download | kvmx-a428e7115bb66e58c8db1039cd9659491dd940a9.tar.gz kvmx-a428e7115bb66e58c8db1039cd9659491dd940a9.tar.bz2 |
Adds ssh_finger action
-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 |