summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2021-10-10 03:49:19 -0400
committerAndrew Cady <d@jerkface.net>2021-10-10 03:49:19 -0400
commit87d4cf6499d009ef927e282fd69a7371be283370 (patch)
tree61657e711263b6908e6740acbd2b223f255931c3
parent03d3d89cdcae262065dbafd72d0d88d052cfc56b (diff)
improve get-host-keys
-rwxr-xr-xget-host-keys23
1 files changed, 14 insertions, 9 deletions
diff --git a/get-host-keys b/get-host-keys
index f55b6cd..90a44db 100755
--- a/get-host-keys
+++ b/get-host-keys
@@ -67,13 +67,13 @@ cd "$_TEMP_DIR_"
67trap 'rm -rf "$_TEMP_DIR_"' EXIT 67trap 'rm -rf "$_TEMP_DIR_"' EXIT
68host=${1:-borges} 68host=${1:-borges}
69 69
70# ssh-keygen -F "${host#*@}" | grep -v '^#' > ssh_known_hosts 2>/dev/null 70if ssh-keygen -F "${host#*@}" | grep -v '^#' > ssh_known_hosts 2>/dev/null
71# touch ssh_known_hosts.stamp -r ssh_known_hosts 71then
72 72 cp ssh_known_hosts ssh_known_hosts~
73line=$(crypto_validate_hostname "$host") || die "could not validate hostname cryptographically" 73else
74 74 touch ssh_known_hosts~
75echo "$line" > ssh_known_hosts 75 crypto_validate_hostname "${host##*@}" >> ssh_known_hosts || die "could not validate hostname cryptographically"
76cp ssh_known_hosts ssh_known_hosts~ 76fi
77 77
78ssh \ 78ssh \
79 -F /dev/null \ 79 -F /dev/null \
@@ -83,7 +83,12 @@ ssh \
83 -o PasswordAuthentication=no \ 83 -o PasswordAuthentication=no \
84 -o StrictHostKeyChecking=yes \ 84 -o StrictHostKeyChecking=yes \
85 -n -T \ 85 -n -T \
86 "$host" >/dev/null 2>&1 86 "$host" >/dev/null 2>&1 || true
87 87
88cat ssh_known_hosts 88if test -t 1
89then
90 diff -u ssh_known_hosts~ ssh_known_hosts
91else
92 cat ssh_known_hosts
93fi
89 94