Logging onto CSU's VPN

If you are lucky enough to have a network drive at CSU, you'd probably be very happy to be able to able to mount it from FreeBSD rather than just Windows. Fortunately, we can do just that.

Connecting to the VPN
Mounting Network Drives
Passwordless Mounting

Connecting to the VPN

Before we can mount our network drives, we will have to connect to the VPN. Fortunately this is a simple process. First we'll install vpnc. Of course you must be root to do so.

cd /usr/ports/security/vpnc
make install clean

Now that it is installed, we'll modify the configuration file.

cd /usr/local/etc
cp vpnc.conf.sample vpnc.conf
vi vpnc.conf

We copied rather than renamed the config file so we'll have the default just in case we need it for future reference. Now change your config file so it looks like this one:

Interface name tun0
IPSec gateway 129.82.80.2
IPSec ID ENGR
IPSec secret engr
Xauth username Engr_dom\reinholz
Xauth password PASSWORD

Now of course you will need to change reinholz to your user name for your engineering account, and PASSWORD to your password. Alternatively you may omit the last line, but you will be prompted for your password everytime you start vpnc. Now that our configuration is set, run this command to log in. Remember you will always need to run vpnc as root.

vpnc

After doing so you will see a nice welcome message.

bsd# vpnc
Connect Banner:
| Welcome to ENGR VPN.
|
|

add host 129.82.80.2: gateway 192.168.1.1
delete net default
add net default: gateway 129.82.18.81
VPNC started in background (pid: 58551)...

Now let us make some use out of this VPN connection...

Mounting Network Drives

In order to mount your network drives you must first be connected to the VPN. I'll assume you've gone through the previous section and done so already (hint hint). First let's make some directories to mount the network drives in.

mkdir /engr /engr_classes
chown xaenn /engr /engr_classes

Of course replace xaenn with the name of your user account. Now let's mount the drives.

mount_smbfs -I bluestore.engr.colostate.edu -W ENGR_DOM //reinholz@bluestore/reinholz /engr
mount_smbfs -I bluestore.engr.colostate.edu -W ENGR_DOM //reinholz@bluestore/classes /engr_classes

After each of those commands you will be prompted for your password. Now enjoy using your network drive from inside FreeBSD. In my case updating the FreeBSD Guide from FreeBSD will be quite nice.

Passwordless Mounting

That's fine and good that we've got our network drive mounted, but the process isn't nearly as clean as it could be. Fortunately, we can setup our shares in fstab, configure mount_smbfs, and finally write a simple script to streamline the process.

vi /etc/fstab

Add two lines to the very bottom:

//reinholz@bluestore/reinholz /engr smbfs rw,noauto 0 0
//reinholz@bluestore/classes /engr_classes smbfs rw,noauto 0 0

Now that we've done that we need to setup some options for mount_smbfs.

touch ~/.nsmbrc
chmod 600 ~/.nsmbrc
vi ~/.nsmbrc

We just created a new file, and made it so nobody but root can read or write it, (your passwords will be in here, so you don't want anybody else to have access to them) and opened it up for editing.

[BLUESTORE]
addr=bluestore.engr.colostate.edu
workgroup=ENGR_DOM

[BLUESTORE:REINHOLZ]
password=PASSWORD

I know that the syntax is a bit cumbersome, but it is due to the restrictions on how you must enter information. Make sure that your username is all caps in the same place that mine is. Now we'll write a quick little script to do this process. First become user however (that way we'll make the script in our user's home directory).

cd ~/bin
touch engr_mount
chmod 755 engr_mount
vi engr_mount

We just created the script, and then made it executable.

#!/bin/sh
vpnc
mount /engr
mount /engr_classes

The script is very simple, and one could make it run at startup, but I'd prefer not to. I don't always need the vpn, and I'm not always online. One final note is that even though you made the script in your user's home directory, you will need to run it as root (don't worry, when you su ~/bin will still be in your path).