From eab4dd464a33f526d1917bfbccda3d14a0edfc74 Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Wed, 19 Sep 2018 00:01:33 -0500 Subject: [PATCH 1/4] Used function to replace repetitive code --- tab-sorcery.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tab-sorcery.sh b/tab-sorcery.sh index a956b8f..1b0b508 100644 --- a/tab-sorcery.sh +++ b/tab-sorcery.sh @@ -8,6 +8,11 @@ scan_domain=$1 scan_ns=$2 +get_hostip () { + #host_ip=`echo $zone_xfer | grep ${host} | grep A | awk '{print $3}'` + host_ip=`echo $zone_xfer | grep $1 | grep A | awk '{print $3}'` +} + zone_xfer=`dig $scan_domain @$scan_ns AXFR | egrep -v 'SOA|NS|MX|DiG' | grep $scan_domain | awk '{print $1,$4,$5}'` for host in `echo $zone_xfer | awk '{print $1}'`; do user_name=$3 @@ -16,22 +21,23 @@ for host in `echo $zone_xfer | awk '{print $1}'`; do if echo $zone_xfer | grep $host | grep TXT; then if [ "`echo $zone_xfer | grep $host | grep TXT | awk '{print $3}'`" = '"lxc"' ]; then user_name="root" - host_ip=`echo $zone_xfer | grep ${host} | grep A | awk '{print $3}'` + get_hostip ${host} alias ${host_short}="${connect_cmd} ${user_name}@${host_ip}" elif [ "`echo $zone_xfer | grep $host | grep TXT | awk '{print $3}'`" = '"windows"' ]; then connect_cmd="rdesktop -g 1600x900" - host_ip=`echo $zone_xfer | grep ${host} | grep A | awk '{print $3}'` + get_hostip ${host} alias ${host_short}="${connect_cmd} -u ${user_name} ${host_ip}" elif [ "`echo $zone_xfer | grep $host | grep TXT | awk '{print $3}'`" = '"cisco"' ]; then connect_cmd="telnet" - host_ip=`echo $zone_xfer | grep ${host} | grep A | awk '{print $3}'` + get_hostip ${host} alias ${host_short}="${connect_cmd} ${host_ip}" fi else - host_ip=`echo $zone_xfer | grep $host | grep A | awk '{print $3}'` + get_hostip ${host} alias ${host_short}="${connect_cmd} ${user_name}@${host_ip}" fi >/dev/null done +unset -f get_hostip return 0 From cc3f3f5ce10843880ce820398b9e09cd5f42c357 Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Wed, 19 Sep 2018 00:21:42 -0500 Subject: [PATCH 2/4] Updated ReadMe --- README.md | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 486dabe..45be17e 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ A helpful script for simplifying connections to servers and devices on your network. ## To use: - +### Shell Setup Add the script as a source file in your shell prompt, such as a line similar to this: ``` @@ -19,3 +19,33 @@ Default username (bob.user) Once done, all hostnames in the DNS zone should be available for SSH/Telnet/RDP by a tab-completable alias of just the hostname (in new shell sessions). +#### Can I change the window geometry for rdesktop? +No. Not yet. You get 1600x900. See the bottom of this ReadMe for details. + + +### DNS Setup +You'll likely want to create a DNS zone specifically for this script for better control over the hosts included. I would recommend using a TLD not normally available, to be sure you don't have any overlap with existing DNS names. This domain doesn't need to be publicly queried, and actually it's probably in interest of security if it isn't. + +The best way to explain the zone set up is by example. Let's assume you create the zone "not-a-real.lan" and you have 5 hosts, known as host1.not-a-real.lan through host5.not-a-real.lan. +If you create the following entries (BIND format shown): +``` +$ORIGIN not-a-real.lan. + +host1 IN A 10.0.0.1 +host2 IN A 10.0.0.2 +host3 IN A 10.0.0.3 +host3 IN TXT "cisco" +host4 IN A 10.0.0.4 +host4 IN TXT "windows" +host5 IN A 10.0.0.5 +``` + +#### How will this work on the client? +In this case, the script will create aliases called host1 through host5. +Hosts 1, 2, and 5 will connect with, for example, `ssh -t your.username@10.0.0.1` +The `host3` alias is tagged with a TXT record for cisco, so it will be: `telnet 10.0.0.3` +`host5` is tagged as a Windows host, so it will use: `rdesktop -g 1600x900 -u your.username 10.0.0.5` + +#### Can I change the window geometry for rdesktop? +This last one, rdesktop, is harcoded to use 1600x900 geometry for now. Very likely, a variable will be added later to allow customization, but for now most people can accomodate 1080p-like resolutions, so this size should be "generally acceptable" for an average workstation. Perhaps a little less-so for a laptop. + From 4f0d255a612dbad946dc1c72d04d30546f7b9b9a Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Wed, 19 Sep 2018 00:26:42 -0500 Subject: [PATCH 3/4] Updated ReadMe --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 45be17e..0579398 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ A helpful script for simplifying connections to servers and devices on your network. -## To use: -### Shell Setup +---------------------- +## Shell Setup Add the script as a source file in your shell prompt, such as a line similar to this: ``` @@ -23,7 +23,7 @@ Once done, all hostnames in the DNS zone should be available for SSH/Telnet/RDP No. Not yet. You get 1600x900. See the bottom of this ReadMe for details. -### DNS Setup +## DNS Setup You'll likely want to create a DNS zone specifically for this script for better control over the hosts included. I would recommend using a TLD not normally available, to be sure you don't have any overlap with existing DNS names. This domain doesn't need to be publicly queried, and actually it's probably in interest of security if it isn't. The best way to explain the zone set up is by example. Let's assume you create the zone "not-a-real.lan" and you have 5 hosts, known as host1.not-a-real.lan through host5.not-a-real.lan. @@ -42,10 +42,14 @@ host5 IN A 10.0.0.5 #### How will this work on the client? In this case, the script will create aliases called host1 through host5. + Hosts 1, 2, and 5 will connect with, for example, `ssh -t your.username@10.0.0.1` + The `host3` alias is tagged with a TXT record for cisco, so it will be: `telnet 10.0.0.3` + `host5` is tagged as a Windows host, so it will use: `rdesktop -g 1600x900 -u your.username 10.0.0.5` + #### Can I change the window geometry for rdesktop? This last one, rdesktop, is harcoded to use 1600x900 geometry for now. Very likely, a variable will be added later to allow customization, but for now most people can accomodate 1080p-like resolutions, so this size should be "generally acceptable" for an average workstation. Perhaps a little less-so for a laptop. From f61d97f5467bf1c27f9f6ced0a361550460814b1 Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Wed, 19 Sep 2018 00:28:26 -0500 Subject: [PATCH 4/4] Updated ReadMe --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0579398..a8dc1ca 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ No. Not yet. You get 1600x900. See the bottom of this ReadMe for details. ## DNS Setup You'll likely want to create a DNS zone specifically for this script for better control over the hosts included. I would recommend using a TLD not normally available, to be sure you don't have any overlap with existing DNS names. This domain doesn't need to be publicly queried, and actually it's probably in interest of security if it isn't. -The best way to explain the zone set up is by example. Let's assume you create the zone "not-a-real.lan" and you have 5 hosts, known as host1.not-a-real.lan through host5.not-a-real.lan. +The best way to explain the zone set up is by example. Let's assume you create the zone "**not-a-real.lan**" and you have 5 hosts, known as *host1.not-a-real.lan* through *host5.not-a-real.lan*. If you create the following entries (BIND format shown): ``` $ORIGIN not-a-real.lan. @@ -41,7 +41,7 @@ host5 IN A 10.0.0.5 ``` #### How will this work on the client? -In this case, the script will create aliases called host1 through host5. +In this case, the script will create aliases called *host1* through *host5*. Hosts 1, 2, and 5 will connect with, for example, `ssh -t your.username@10.0.0.1`