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””
Leave a Reply
Site by Robert Spanton. ©2008






June 11th, 2008 at 12:06 pm
:o bashisms!
June 11th, 2008 at 12:32 pm
Hey Chris!
It’s labelled with #!/bin/bash though!
June 12th, 2008 at 3:38 am
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.
June 12th, 2008 at 9:44 am
Nice work Chris. I like the sysfs usage, and I’ve changed mine to use exec. None of this ifdata malarky though ;-)