I am forgetful, plain and simple. I have a server at home that I can access over ssh from anywhere. However, there are two different addresses to the server whether I am at home or elsewhere. To do this, I created a simple bash script:

if iwconfig eth1 | grep -q "WLS_SSID"
  echo "Connecting to ginny locally"
  ssh ginny
  echo "Connecting to ginny through internet"

Place the code in /home/<username>/bin and give it executable permissions.

Ginny is the name of my home server. Replace the SSID and IP_OR_DDNS_ADDR with their corresponding values. This only works if your wireless interface is ‘eth1’ (wireless on most laptops). Should be able to be modified to work for other interfaces.

Use this freely, I claim no copyright on it.

Be Sociable, Share!