# HG changeset patch # User Steve Huston # Date 1583272139 18000 # Node ID 83f16440575579600350a82e41c180a5cfd36318 # Parent daa1d18ece79c14ac77ad362986d46f5288c8b78 New 'onsubnet' command, new config for master controls diff -r daa1d18ece79 -r 83f164405755 .ssh/config --- a/.ssh/config Tue Mar 03 15:59:27 2020 -0500 +++ b/.ssh/config Tue Mar 03 16:48:59 2020 -0500 @@ -4,6 +4,22 @@ ForwardX11 no ForwardX11Trusted no +# Let's try a proxy connection here +Host xanadu.astro.princeton.edu + User huston + ControlMaster auto + ControlPersist yes + ControlPath ~/.ssh/sockets/%C + +Match host csesbh2.princeton.edu exec "~/.ssh/onsubnet --not 128.112." + ProxyJump xanadu.astro.princeton.edu + +Host csesbh2.princeton.edu + User huston + ControlMaster auto + ControlPersist yes + ControlPath ~/.ssh/sockets/%C + # xanadu-vm and syrinx's keys change, let's try to avoid errors Host xanadu-vm syrinx xanadu-vm.astro.princeton.edu syrinx.astro.princeton.edu User huston diff -r daa1d18ece79 -r 83f164405755 .ssh/onsubnet --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.ssh/onsubnet Tue Mar 03 16:48:59 2020 -0500 @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]] || [[ "$1" == "" ]] ; then + printf "Usage:\n\tonsubnet [ --not ] partial-ip-address\n\n" + printf "Example:\n\tonsubnet 10.10.\n\tonsubnet --not 192.168.0.\n\n" + printf "Note:\n\tThe partial-ip-address must match starting at the first\n" + printf "\tcharacter of the ip-address, therefore the first example\n" + printf "\tabove will match 10.10.10.1 but not 110.10.10.1\n" + exit 0 +fi + +on=0 +off=1 +if [[ "$1" == "--not" ]] ; then + shift + on=1 + off=0 +fi + +regexp="^$(sed 's/\./\\./g' <<<"$1")" + +if [[ "$(uname)" == "Darwin" ]] ; then + ifconfig | fgrep 'inet ' | fgrep -v 127.0.0. | cut -d ' ' -f 2 | egrep -q "$regexp" +else + hostname -I | tr -s " " "\012" | fgrep -v 127.0.0. | egrep -q "$regexp" +fi + +if [[ $? == 0 ]]; then + exit $on +else + exit $off +fi