Tuesday, July 3, 2012

Cisco VPN on Linux on campus

Now that I'm at UH this is the second time I've had to do something like this, so I thought I'd throw together a post about it in case someone else is trying to do the same, or in case I set up a new machine and have to do it again...

Since I'm apparently unable to use my Linux Mint 12 system (64-bit, Ubuntu-based) with the secure wireless network here on campus, I decided to set up the VPN, at least for the time being. The problem is that the Linux VPN software that's available from the university's website won't install. It requires building a kernel module, but it seems to be assuming an older kernel, because I get a ton of messages about header files missing like linux/config.h. Some research shows that this file (and others) were deprecated and removed from the kernel source somewhere around 2.6, and I'm running 3.0.0-12 (64-bit).

I searched a bit online and found an article named "How To: Install Cisco VPN Client on Linux Mint 12 (64 bit)". I thought to myself "Hey, that's exactly what I'm trying to do!" so I followed the instructions. Make sure to read the output when the vpn_install script finishes, especially this one:

* You must run "/etc/init.d/vpnclient_init start" before using the client.

That must be done as root (or via sudo), otherwise you will find that the VPN interface isn't available when you try to connect. You should only need to do this once, provided that you chose the default option to automatically start the VPN service at boot time.

After the installation is done and you've started the service, in Linux Mint 12 you need to go to System Settings > Network and do the following:

1) Click the [+] button to add a new interface.
2) Choose VPN and click "Create..."
3) Choose "Cisco Compatible VPN (vpnc)" and click "Create..."
4) Set the connection details.

This step is where it can get tricky again, since the Cisco VPN setup requires both your individual username/password and a group username/password. Every place I've checked keeps this information secure, so you'll need to do a little work to get this information. I'm not going to post the actual group information here for obvious reasons, though I can certainly tell you how I found the info.

UH (like all other places I've dealt with) requires that you log in to access their VPN configuration information (the PCF files). UH actually goes so far as to not allow download of the VPN client at all without logging in. I was able to retrieve the remaining setting information by logging in, downloading the VPN software for Windows, extracting it, and opening up the PCF file in a text editor. This file contains a lot of configuration data, but most notably it includes the gateway, group name, and group password. The group password is encrypted, so it's necessary to decode the password so you can enter this into the settings. (It's easy enough to find a decrypting utility online, so I'm not going to link to one in particular.)

After you've gathered the information, you'll need to at least enter the following:
  • Connection Name: Whatever you'd like, but know that it will append "VPN", so entering just "UH" will give you an interface named "UH VPN".
  • Gateway: This is normally an IP address. Get it from your university's connection information page (e.g. UH's), if available, or get from the PCF file.
  • User name: Your campus-provided username.
  • Group name: Get this from the PCF file, if not otherwise provided.
Optionally, you can also enter:
  • User password: Your campus-provided password.
  • Group password: Get this from the PCF file, if not otherwise provided.
If you don't want to be prompted for the passwords every time make sure to change the options to save them. I entered the passwords in the config screen, however I was then prompted for them when I first connected to the VPN...

The last bit of configuration is that you may need to enter a domain, particularly if your university is really into Windows networking. This is necessary for UH. To enter this into the configuration click "Advanced", enter the domain (e.g. "cougarnet") into the appropriate box, and save.

With any luck you can now access the VPN!

Hopefully this will be helpful, and please feel free to leave any comments, questions, etc.


Also, I'd be interested in knowing if any fellow Cougars have managed to get their Linux system connected to the UHSecure network, since that's what I was trying to do in the first place!


Friday, June 1, 2012

mutt for gmail on cygwin

I wanted to set up mutt to check my gmail and google apps accounts on cygwin and it took a bit of trial and error, since the default mutt build in cygwin isn't configured appropriately for this setup. I installed mutt using cygwin's setup.exe, then went searching for configuration examples. The best starting point I found was the following:

http://lifehacker.com/5574557/how-to-use-the-fast-and-powerful-mutt-email-client-with-gmail

This site gives some instructions along with a sample .muttrc:

# A basic .muttrc for use with Gmail

# Change the following six lines to match your Gmail account details
set imap_user = "YOUR.EMAIL@gmail.com"
set imap_pass = "PASSWORD"
set smtp_url = "smtp://YOUR.EMAIL@smtp.gmail.com:587/"
set smtp_pass = "PASSWORD"
set from = "YOUR.EMAIL@gmail.com"
set realname = "YOUR NAME"

# Change the following line to a different editor you prefer.
set editor = "nano"

# Basic config, you can leave this as is
set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
set imap_check_subscribed
set hostname = gmail.com
set mail_check = 120
set timeout = 300
set imap_keepalive = 300
set postponed = "+[GMail]/Drafts"
set record = "+[GMail]/Sent Mail"
set header_cache=~/.mutt/cache/headers
set message_cachedir=~/.mutt/cache/bodies
set certificate_file=~/.mutt/certificates
set move = no
set include
set sort = 'threads'
set sort_aux = 'reverse-last-date-received'
set auto_tag = yes
ignore "Authentication-Results:"
ignore "DomainKey-Signature:"
ignore "DKIM-Signature:"
hdr_order Date From To Cc
alternative_order text/plain text/html *
auto_view text/html
bind editor complete-query
bind editor ^T complete
bind editor noop

# Gmail-style keyboard shortcuts
macro index,pager y "unset trash\n " "Gmail archive message"
macro index,pager d "set trash=\"imaps://imap.googlemail.com/[GMail]/Bin\"\n " "Gmail delete message"
macro index,pager gi "=INBOX" "Go to inbox"
macro index,pager ga "=[Gmail]/All Mail" "Go to all mail"
macro index,pager gs "=[Gmail]/Starred" "Go to starred messages"
macro index,pager gd "=[Gmail]/Drafts" "Go to drafts"

I copied this to my home directory, made the appropriate changes, ran mutt, and then began reading ensuing the error messages...

$ /usr/bin/mutt
Error in /home/peter/.muttrc, line 6: smtp_url: unknown variable
Illegal instruction (core dumped)

The first line was straightforward enough, so I commented that line out, re-ran mutt, commented out another line noted in the next error, and so on, but I quickly found that the stock mutt build isn't compiled with support for much:

$ /usr/bin/mutt -v
Mutt 1.5.20 (2009-12-10)
Copyright (C) 1996-2009 Michael R. Elkins and others.
Mutt comes with ABSOLUTELY NO WARRANTY; for details type `mutt -vv'.
Mutt is free software, and you are welcome to redistribute it
under certain conditions; type `mutt -vv' for details.

System: CYGWIN_NT-6.1 1.7.15(0.260/5/3) (i686)
ncurses: ncurses 5.7.20091227 (compiled with 5.7)
libiconv: 1.13
hcache backend: GDBM version 1.8.3. 10/15/2002 (built Feb 26 2009 02:58:00)
Compile options:
-DOMAIN
-DEBUG
-HOMESPOOL -USE_SETGID -USE_DOTLOCK -DL_STANDALONE +USE_FCNTL -USE_FLOCK
+USE_POP +USE_IMAP -USE_SMTP
+USE_SSL_OPENSSL -USE_SSL_GNUTLS -USE_SASL -USE_GSS +HAVE_GETADDRINFO
+HAVE_REGCOMP +USE_GNU_REGEX
+HAVE_COLOR +HAVE_START_COLOR +HAVE_TYPEAHEAD +HAVE_BKGDSET
+HAVE_CURS_SET +HAVE_META +HAVE_RESIZETERM
+CRYPT_BACKEND_CLASSIC_PGP +CRYPT_BACKEND_CLASSIC_SMIME -CRYPT_BACKEND_GPGME
-EXACT_ADDRESS -SUN_ATTACHMENT
+ENABLE_NLS +LOCALES_HACK +HAVE_WC_FUNCS +HAVE_LANGINFO_CODESET +HAVE_LANGINFO_YESEXPR
+HAVE_ICONV -ICONV_NONTRANS -HAVE_LIBIDN +HAVE_GETSID +USE_HCACHE
-ISPELL
SENDMAIL="/usr/sbin/sendmail"
MAILPATH="/var/spool/mail"
PKGDATADIR="/usr/share/mutt"
SYSCONFDIR="/etc"
EXECSHELL="/bin/sh"
-MIXMASTER
To contact the developers, please mail to mutt-dev@mutt.org.
To report a bug, please visit http://bugs.mutt.org/.
mutt-dev@mutt.org

No SMTP support is the big problem, so I knew right away that a rebuild was needed. I installed the mutt source package, which gave me the source tree in /usr/src/mutt-1.5.20-1/, but then there was the issue of configuring. Much to my display, I got errors when I even tried to run ./configure!

After a little more research I found that I needed to run the following command:

autoreconf -f -i -Wall,no-obsolete

Fortunately this worked and I could now proceed with the build. Here are the options I ended up needing:

./configure --enable-imap --enable-pop --with-ssl --enable-smtp --with-homespool=mailspool --enable-hcache --enable-debug --with-sasl

You can easily leave out --enable-debug, but I left this in to help with future troubleshooting. I also needed to install a couple packages through cygwin, though I regret that I didn't keep a list. If you use these instructions it would be nice if you could leave a comment noting what extra packages you needed to install.

After configure and a make install, I now have a working mutt at /usr/local/bin/mutt with the following options:

$ /usr/local/bin/mutt -v
Mutt 1.5.20 (2009-12-10)
Copyright (C) 1996-2009 Michael R. Elkins and others.
Mutt comes with ABSOLUTELY NO WARRANTY; for details type `mutt -vv'.
Mutt is free software, and you are welcome to redistribute it
under certain conditions; type `mutt -vv' for details.

System: CYGWIN_NT-6.1 1.7.15(0.260/5/3) (i686)
ncurses: ncurses 5.7.20091227 (compiled with 5.7)
libiconv: 1.14
hcache backend: GDBM version 1.8.3. 10/15/2002 (built Feb 26 2009 02:58:00)
Compile options:
-DOMAIN
+DEBUG
+HOMESPOOL -USE_SETGID +USE_DOTLOCK -DL_STANDALONE +USE_FCNTL -USE_FLOCK
+USE_POP +USE_IMAP +USE_SMTP
+USE_SSL_OPENSSL -USE_SSL_GNUTLS +USE_SASL -USE_GSS +HAVE_GETADDRINFO
+HAVE_REGCOMP -USE_GNU_REGEX
+HAVE_COLOR +HAVE_START_COLOR +HAVE_TYPEAHEAD +HAVE_BKGDSET
+HAVE_CURS_SET +HAVE_META +HAVE_RESIZETERM
+CRYPT_BACKEND_CLASSIC_PGP +CRYPT_BACKEND_CLASSIC_SMIME -CRYPT_BACKEND_GPGME
-EXACT_ADDRESS -SUN_ATTACHMENT
+ENABLE_NLS -LOCALES_HACK +HAVE_WC_FUNCS +HAVE_LANGINFO_CODESET +HAVE_LANGINFO_YESEXPR
+HAVE_ICONV -ICONV_NONTRANS -HAVE_LIBIDN +HAVE_GETSID +USE_HCACHE
-ISPELL
SENDMAIL="/usr/sbin/sendmail"
MAILPATH="mailspool"
PKGDATADIR="/usr/local/share/mutt"
SYSCONFDIR="/usr/local/etc"
EXECSHELL="/bin/sh"
-MIXMASTER
To contact the developers, please mail to mutt-dev@mutt.org.
To report a bug, please visit http://bugs.mutt.org/.
mutt-dev@mutt.org

Enjoy!