From cbe5f594b5e23a9f55d5ee578bdc8d39eed6763a Mon Sep 17 00:00:00 2001 From: Joel Beckmeyer Date: Fri, 28 Jul 2023 09:43:32 -0400 Subject: [PATCH] add ssh tooling --- bin/executable_ssh-check-host-fingerprint | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 bin/executable_ssh-check-host-fingerprint diff --git a/bin/executable_ssh-check-host-fingerprint b/bin/executable_ssh-check-host-fingerprint new file mode 100644 index 0000000..428548f --- /dev/null +++ b/bin/executable_ssh-check-host-fingerprint @@ -0,0 +1,17 @@ +#!/bin/sh +tmpfile=$(mktemp /tmp/ssh-check-host-fingerprints.tmp.XXXXXX) +ssh-keyscan -p "$2" "$1" 2>/dev/null > "$tmpfile" +if [ -s "$tmpfile" ]; then + fingerprints=$(ssh-keygen -lf "$tmpfile" 2>/dev/null | awk '{print $2}') + for fingerprint in $fingerprints + do + if [ "$fingerprint" = "$3" ]; + then + rm "$tmpfile" + exit 0 + fi + done +else + rm "$tmpfile" + exit 1 +fi