aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-06-13 13:29:58 -0300
committerSilvio Rhatto <rhatto@riseup.net>2018-06-13 13:29:58 -0300
commita428e7115bb66e58c8db1039cd9659491dd940a9 (patch)
treeee3c7eae5f7cbb5643fc99fa0fbb4bf3de350776
parent80d7be771c6e442e46c74bedb71207fdf6400fa6 (diff)
downloadkvmx-a428e7115bb66e58c8db1039cd9659491dd940a9.tar.gz
kvmx-a428e7115bb66e58c8db1039cd9659491dd940a9.tar.bz2
Adds ssh_finger action
-rwxr-xr-xkvmx34
1 files changed, 34 insertions, 0 deletions
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