diff options
author | Andrew Cady <d@jerkface.net> | 2021-10-10 03:49:19 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2021-10-10 03:49:19 -0400 |
commit | 87d4cf6499d009ef927e282fd69a7371be283370 (patch) | |
tree | 61657e711263b6908e6740acbd2b223f255931c3 | |
parent | 03d3d89cdcae262065dbafd72d0d88d052cfc56b (diff) |
improve get-host-keys
-rwxr-xr-x | get-host-keys | 23 |
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_" | |||
67 | trap 'rm -rf "$_TEMP_DIR_"' EXIT | 67 | trap 'rm -rf "$_TEMP_DIR_"' EXIT |
68 | host=${1:-borges} | 68 | host=${1:-borges} |
69 | 69 | ||
70 | # ssh-keygen -F "${host#*@}" | grep -v '^#' > ssh_known_hosts 2>/dev/null | 70 | if ssh-keygen -F "${host#*@}" | grep -v '^#' > ssh_known_hosts 2>/dev/null |
71 | # touch ssh_known_hosts.stamp -r ssh_known_hosts | 71 | then |
72 | 72 | cp ssh_known_hosts ssh_known_hosts~ | |
73 | line=$(crypto_validate_hostname "$host") || die "could not validate hostname cryptographically" | 73 | else |
74 | 74 | touch ssh_known_hosts~ | |
75 | echo "$line" > ssh_known_hosts | 75 | crypto_validate_hostname "${host##*@}" >> ssh_known_hosts || die "could not validate hostname cryptographically" |
76 | cp ssh_known_hosts ssh_known_hosts~ | 76 | fi |
77 | 77 | ||
78 | ssh \ | 78 | ssh \ |
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 | ||
88 | cat ssh_known_hosts | 88 | if test -t 1 |
89 | then | ||
90 | diff -u ssh_known_hosts~ ssh_known_hosts | ||
91 | else | ||
92 | cat ssh_known_hosts | ||
93 | fi | ||
89 | 94 | ||