I wanted to always be able to shell to a machine within the Uni network. The Uni network has a firewall that stops incoming requests to most machines. There’s a machine that all undergrads can shell to, which I normally use netcat combined with the ssh ProxyCommand setting. However, it’s a little silly to divert all traffic through another machine when I’m in the network. So, meet the new script I use in the ProxyCommand:
#!/bin/bash HOST=$1 got=`ifconfig eth1 | egrep -o "inet addr:152.78.[0-9]{1,3}\\.[0-9]{1,3}"` got+=`ifconfig eth0 | egrep -o "inet addr:152.78.[0-9]{1,3}\\.[0-9]{1,3}"` if [[ "$got" == "" ]] then ssh uglogin.ecs.soton.ac.uk nc $HOST 22 else nc $HOST 22 fi
Posted at 8:38 am on Wednesday 11th June 2008
4 responses to “Location sensitive ssh “tunnelling””
Site by Rob Gilton. © 2008 - 2019
:o bashisms!
Hey Chris!
It’s labelled with #!/bin/bash though!
http://lamby.uwcs.co.uk/b/xgoat.sh.txt seems a little nicer.. will use this on my laptop now.
Hm, I fear parsing IP addresses with regular expressions is conCIDRed harmful.
Nice work Chris. I like the sysfs usage, and I’ve changed mine to use exec. None of this ifdata malarky though ;-)