Monday, March 26, 2007

Cisco VPN bash script

I wrote a little bash script to allow you to start and stop the service as well as connect and disconnect a little easier. The main reason I had to do this is I didn't want the service running all of the time since I only use it infrequently to connect to my work.

I found a place that has the client as well as instructions for installing the client here

You do need the kernel source to compile this, you can run this command in the console window to download the ones specific for the kernel you are using.

sudo apt-get install build-essential linux-headers-'uname -r'

I then followed the steps in the document with only a minor change. The question "Automatically start the VPN service at boot time [yes]" I of course told it no.

I ended before "Load the VPN client's module into the running kernel:" as that is what my bash script is for.

You need to get the profile for your VPN client, I had a profile for mine that uses a key token. I put the profile in the same directory as the VPN client /etc/opt/cisco-vpnclient and deleted all of the original ones in there.

Finally I put the bash file (named vpn) with executable permissions a folder in my path file /home/bin for me which defaults as a user path in Ubuntu. Here is the bash file.

case $1 in
start) sudo /etc/init.d/vpnclient_init start;;
connect) sudo vpnclient connect [vpn_profile];;
stop) sudo /etc/init.d/vpnclient_init stop;;
dis) sudo vpnclient disconnect;;
*) echo "Only use start, stop, connect and dis";;

Make sure you change [vpn_profile] to your actual profile.

To use just open up your console of choice and type "vpn start" to start the service, "vpn connect" to connect using your profile specified above, "vpn dis" to disconnect, and finally "vpn stop" to stop the service.

1 comment:

alex smith said...

Tried numerous vpn providers prior to finding StrongVPN. All other providers proved to be consistently inconsistent, whereas StrongVPN from the get go proved to be outstanding. Not only is the setup very simple, even for non IT geeks, the customer support is the best I have seen to date, facilitated by the use of SKYPE. I am now a customer for life.