dotfiles/bin/executable_ssh-check-host-fingerprint

19 lines
397 B
Plaintext
Raw Normal View History

2023-07-28 09:43:32 -04:00
#!/bin/sh
2023-08-07 09:07:03 -04:00
tmpdir=${TMPDIR:-/tmp}
tmpfile=$(mktemp "$tmpdir"/ssh-check-host-fingerprints.tmp.XXXXXX)
2023-07-28 09:43:32 -04:00
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