Quick script for connecting to University VPN

I can be pretty lazy at times, so much that I will go out of my way a bit to write a bit of code to simplify my life. I don’t often connect to my university’s VPN, but when I eventually do want to, I can never remember the command needed to do it. So I have to take the time and look it up. Well I cut that out today with a basic little bash script with a name I can remember when I need it. I titled my script “rice_proxy.sh” but anything memorable to you would be fine. The script takes one argument (“on” or “off”) to either connect or disconnect with the proxy. Stick the script in your bin folder and it will execute simply with rice_proxy.sh on.

The script is reproduced below, or you can grab it from here.

#!/bin/bash
# Andrew J. Moodie
# Feb 2015
# easily remembered interface for vpn connection
if [ "$1" = "on" ]
    then
    sudo /usr/sbin/vpnc RiceVPN.conf
elif [ "$1" = "off" ]
    then
    vpnc­-disconnect
else
    echo " input error -- one argument must be given"
    echo " valid inputs: 'on' or 'off'"
fi

Note that you could further automate this if you wanted to (e.g. auto-enter passwords, connect on startup), but this is a bad idea for both security and for internet speed.

Leave a Reply

Your email address will not be published. Required fields are marked *