Skip to content

Commit

Permalink
Update sshprep
Browse files Browse the repository at this point in the history
Co-Authored-By: William Stearns <[email protected]>
  • Loading branch information
caffeinatedpixel and william-stearns committed Aug 20, 2024
1 parent e5fbb07 commit 93b2dc5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions installer/install_scripts/sshprep
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
#Released under the GPL 3.0
#Version 0.1.6
#Version 0.1.7



Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 93b2dc5

Please sign in to comment.