From 93b2dc566cfac5aab83d050ed8eec7def15181e9 Mon Sep 17 00:00:00 2001 From: Naomi Kramer Date: Tue, 20 Aug 2024 10:23:04 -0400 Subject: [PATCH] Update sshprep Co-Authored-By: William Stearns <3538265+william-stearns@users.noreply.github.com> --- installer/install_scripts/sshprep | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/installer/install_scripts/sshprep b/installer/install_scripts/sshprep index 66197c6..1fc53cb 100755 --- a/installer/install_scripts/sshprep +++ b/installer/install_scripts/sshprep @@ -2,7 +2,7 @@ #Performs all the setup steps needed to connect to one or more hosts listed on the command line #Copyright 2022 William Stearns #Released under the GPL 3.0 -#Version 0.1.6 +#Version 0.1.7 @@ -230,8 +230,8 @@ check_config_block() { prepend_config_block "\nHost ${2} ${local_ip}\n\tHostname\t\t${local_ip}\n\tHostKeyAlias\t\t${2}\n${user_line}\n" else status "No user-supplied target IP or hostname for $2, look one up" - ip4=$(dig +short ${2} A) - ip6=$(dig +short ${2} AAAA) + ip4=$(dig +nocomment +short ${2} A 2>/dev/null | sed -e 's/;;.*//' | grep -v '^$') + ip6=$(dig +nocomment +short ${2} AAAA 2>/dev/null | sed -e 's/;;.*//' | grep -v '^$') if [ -n "$ip4" ]; then if [ -n "$ip6" ]; then @@ -246,8 +246,13 @@ check_config_block() { status "Have an ipv6 address only for $2" prepend_config_block "\nHost ${2} ${2}-v6 ${ip6}\n\tHostname\t\t${ip6}\n\tHostKeyAlias\t\t${2}\n${user_line}\n" else - status "No ipv4 or ipv6 address found for ${2}. Please enter an IP address to use:" - read ip_or_hostname + #echo "== No ipv4 or ipv6 address found for ${2}. Please enter an IP address to use:" >&2 + #read ip_or_hostname <&2 + #if [ -z "$ip_or_hostname" ]; then + # ip_or_hostname="$2" + #fi + status "We could not lookup a DNS address for $2 so we will just use $2 in the ssh Hostname field." + ip_or_hostname="$2" prepend_config_block "\nHost ${2} ${ip_or_hostname}\n\tHostname\t\t${ip_or_hostname}\n\tHostKeyAlias\t\t${2}\n${user_line}\n" fi fi