OpenID Authentication Plugin for vBulletin 4

Recently I volunteered to help fix an existing project or develop an OpenID authentication plugin for the vBulletin platform. The group in need was UbuntuForums.org and I would have never known if it hadn’t been for Jorge Castro’s public request for help.

The Story

The existing plugin had been developed specifically for vBulletin 3.x, however, they are (as of writing this) in the process of upgrading their forums to vBulletin 4 especially wanted OpenID to be available when they make the upgrade. That’s where I came in.

Canonical, the company behind Ubuntu, provided me with necessary software licenses for vBulletin 4 and from there it was a lot of late nights attempting to simply get a successful OpenID process to occur.

Working a full time job doesn’t make projects like this as easy as I remember them once being… Nonetheless I was able to successful port the plugin to vB4 where there were several significant differences that took me some time to address and to be honest, the previous code was a bit more complicated to follow than it should have been.

One major change from vB3 to vB4 was the way templates work. I’d never worked with vBulletin before, but I’ve had an extensive amount of experience with phpBB and bbPress in the past. After getting over the frustration of how vBulletin prefers to store ALL template information (in the database rather than pull from template files) I was ready to begin the repair process.

One major annoyance was that vBulletin 4 kept a “deprecated” method intact for vb3 templates that haven’t yet been ported and the deprecated method would printout a warning on the live page letting you know that you should update your templates. That’s not a problem, but vBulletin likes to only release helpful information to License holding, account proving customers. I had a license yes, but was not the owner and unfortunately I was unable to get much of a response from the Ubuntu mailing list about getting access to vBulletin’s online support section.

For anyone having similar issues, I’ve posted the error message that I first came across below. If you got here, then you probably found the vBulletin post regarding this, but if you don’t have access like I didn’t then you’re still in luck…

Warning: fetch_template() calls should be replaced by the vB_Template class in [path]/includes/functions.php on line

While it was pretty clear that fetch_template() was deprecated, I was unable to get a clear usage example of how to use the new vB_Template class. I finally came across a post on StackOverflow that was exactly what I needed. Other issues that I had with fixing the plugin were some issues with SQL queries and were much more critical.

I wrote an article recently on how to debug PHP in real time as you’re using/executing a page or function… all through the very well known Eclipse IDE. If you’re interested in PHP development then you should certainly take a look at that post as it walks you through the setup and will make your life much easier. After tracing through the code over and over, each time finding new little issues and having to walk through the entire log in process again each time… I’d finally managed to get a successful authentication. So, I took a screenshot of my development environment…

vBulletin OpenID Plugin First Success

It wasn’t long after the first success that I was able to pin point other problematic spots faster and then from there everything just fell into place. In fact I had “full functionality” only about an hour after the first success. That didn’t mean that I was finished.

There were still a lot of minor issues that I’d found with the code. Array index out of bounds, corrupt query results in some situations causing a critical database error page to appear, unhandled invalid urls would take the plugin for a ride and ultimately crash, etc.

I’ve now worked out all of the issues that I came across from my own testing. Hopefully Ubuntu and Canonical won’t find any either and the upgrade can occur soon!

Download for Free

If you’re here for this plugin then I’m sure you’ve seen that there aren’t many (dare I say any) that are working, free or at least reasonably priced. Fortunately this plugin is based on an open source PHP OpenID library and Canonical apparently plans to maintain it from here on out in their source control service.

Before you download: I’ve posted a direct download the vanilla release that I first pushed to Canonical, however, its in your best interest to check for a newer version on their source control page for this plugin. That being said, feel free to continue on to download!

Download from me (last updated 2012-09-29)

Download from Canonical

Installation

This plugin contains a README and INSTALL file that should go into plenty of detail to help you install and get going in no time at all. The only thing that is left for you is to optionally improve on the simplistic log in form as seen below.

vBulletin Simplistic OpenID Login Form

While I do indeed love web design and development, I left the OpenID log-in form simplistic for one reason: Every web designer designs differently and its a waste of my time to put much effort into this when people who use it will likely want to use it in a way I never considered. The good news is that, it doesn’t appear in the header by default, so you can actually place this little form ANYWHERE you want. However, due to obvious reasons, you’ll likely find the header as I’ve done to be easiest as it automatically disappears one the user is logged in.

Conclusion

It’s been a fun month or month and a half that I’ve spent dabbling on this plugin. I’m always happy to contribute where I can to communities that I’m interested in or proud of and I consider this volunteer effort to be no different.

I’m also a little excited to see how the vBulletin community accepts this plugin. Will it be a boom or a bust? Only time will tell, but until then hopefully UbuntuForums.org will be enjoying OpenID functionality!

Debugging PHP in Ubuntu using Eclipse

This guide walks you through the necessary steps to configure the Eclipse IDE for PHP debugging. This can be very handy, especially when you’re trying to resolve an issue in a complex PHP application or plug-in.

Things you’ll need

  • Eclipse
  • Eclipse PHP Development Tools (PDT)
  • Xdebug
Assumptions
This article assumes that you are configuring Eclipse and Xdebug for development on a localhost web server. If you are not, be sure to make appropriate adjustments to accommodation your needs. Likely the only changes you will need to make will be differences in connecting to your server verses localhost.

Quick Overview

For those that are unaware, Eclipse is a very popular IDE for developing in Java. However, Eclipse is much more powerful than that and can in fact easily be used for developing in many other languages including PHP.

Xdebug is a brilliant debugging extension designed for use with PHP. Once configured, Xdebug will allow you to remotely connect to your web server… or in my case connect to my development localhost web server. Rather than using crude echo and logging techniques to debug your PHP code, Xdebug allows you to literally step through and inspect values and function flows in real-time.

If you’ve ever scratched your head at a PHP script and thrown in dozens of echos or logging statements to track the execution path then you’ll really come to appreciate the benefits of using Xdebug.

Configuring Eclipse and Xdebug isn’t difficult. In fact its painless with the correct steps on hand. That’s where this guide comes in. I found myself coming across incomplete or outdated forum posts and stackoverflow questions, so I thought I’d post what worked for me.

If you already have Java and Eclipse installed, then just jump ahead to installing and configuring the PHP Development Tools and Xdebug.

Install Eclipse

This will install ~118 new packages, assuming you’ve not already installed some of them, and will total around 255 MB that need to be downloaded.

  1. Open a terminal and enter the following command to install Eclipse:
    sudo apt-get install eclipse

     

  2. After the download completes, open Eclipse to confirm that it installed correctly. Leave it open for our next install.

Install PHP Development Tools (PDT)

  1. If you don’t have Eclipse open at this point, open it up.
  2. Navigate through the menus to: Help -> Install New Software…
  3. You will be prompted with a new window asking you to select a site or enter the location of a site. You should be able to drop down the list of sites and find one labeled “–All Available Sites–”. Select this option and wait for the list below to populate.

  4. Scroll through the list until you find a category labeled “Programming Languages” and click the arrow to expand this list.

  5. Continue to scroll through the Programming languages until you find a item labeled “PHP Development Tools (PDT) SDK Feature” and check the box to the left.

  6. Click Next and continue throw the installation. You’ll have to select that you agree to the terms of installing this software.
  7. After the installation has completed, you will be asked to restart Eclipse to apply changes. Go ahead and restart Eclipse, then move on to the next install.

 

Install XDebug

  1. Open a terminal and enter the following command to install Xdebug:


    sudo apt-get install php5-xdebug
     

  2. After installation completes, there are a couple of files that need to be configured. If you copy and paste the commands below, make sure to check that the quotes that are copied over are regular quotation characters, as they may cause problems if they are not.
    1. sudo gedit /etc/php5/conf.d/*xdebug.ini 


      zend_extension=/usr/lib/php5/20100525/xdebug.so

      xdebug.remote_enable = 1
      xdebug.remote_handler = “dbgp”
      xdebug.remote_host = “localhost”
      xdebug.remote_port = 9000 

    2. sudo gedit /etc/php5/apache2/php.ini 

      Scroll to the bottom and add:

      zend_extension=/usr/lib/php5/20100525/xdebug.so

  3. Restart your Apache server so that the new PHP configuration settings are loaded.

    sudo /etc/init.d/apache2 restart

  4. Confirm that your Xdebug installation was successfully loaded by creating a simple PHP file called “phpinfo.php” and placing it in the public root of your Apache web server. Be sure to include the following in your file, save it then navigate to it in your browser:

    <?php phpinfo(); ?>

  5. After loading the php info page, search for “xdebug”. If you find it listed, then you have successfully installed and configured Xdebug. If not, check back over the steps listed above or consult Google.
Configuring your Eclipse project to connect to Xdebug
After you’ve finally gotten everything installed, you’re probably anxious to start debugging. You’re not far off. The only thing that’s left is to import your PHP script or site and establish a Debug Configuration for your project.
To import a site, simple select: File -> New -> Project… -> PHP -> PHP Project. This will open a new window where you can open PHP files from and existing location. Assuming this location is in your public root directory in Apache, you can work with these scripts in real-time.
After importing these existing files, right click on your new project and select: Debug As -> Debug Configurations…
Make sure that you’ve selected Xdebug as the Debugger type. Click Apply and then Debug. This will open a “Debug” perspective in Eclipse, allowing you to view variables and stack traces live. Assuming you’ve created a breakpoint or selected to break at the first line of the file, you should now see your PHP script paused waiting for you to debug!
Tip: If you’re planning to debug a large project such as a WordPress, phpBB, vBulletin or any other large web application, pointing the Debug Configuration to your index.php makes debugging much easier.
Done
Congrats! By now you should be beginning a new road to a much easier life of PHP development.
If you have any questions, comments or suggests feel free to let me hear them below! I’ll try to help where I can, but I can guarantee I’ll know how to solve any of the issues you may encounter. ;)

Making CSS UL Menu’s Browser-Consistent

If you’ve ever made a web site and wanted it to look consistent from one browser to the next, then you’re well away of the difficulties that are involved. Fixing these sorts of styling issues can be a major annoyance, however, I like to hunt down issues on my own pages from time to time and stand up to the challenge.

One issue that I can across today was dealing with horizontal menu positioning using unordered lists (<UL>) and some positioning. The positioning wasn’t consistent between browsers or even operating systems.

The bad

I started by opening the affected page in multiple browsers (Internet Explorer, Safari, Chrome, Opera & Firefox) on multiple computers (Mac, Linux & Windows) and getting some initial comparisons. There were 3 different variations and (oddly enough) the same browser didn’t necessarily render the same on a different operating system. So there I was. A puzzle… and I like puzzles.

Some of the first things that I inspected were font sizes and families. It occurred to me that different operating systems may differ in fonts, so it seemed like a good starting point. I tested this by forcing a common font: Arial. That wasn’t the problem. The inconsistencies remained consistent.

I also checked into the possibility that the <UL> or <A> elements were applying different heights. Typically anchor elements, <A>, use a display style of inline. If you’re implementing a menu similar to mine then you’re likely applying a block style, which permits better dimension definition of the element. Forcing height on these elements also did not resolve the issue.

I was running out of ideas, but then it hit me. Line-Height. While the other styles appeared to be consistent between browsers and operating systems, there was one style that I’d previously worked with and knew was certainly NOT consistent: line-height.

The good

After forcing a consistent line-height in my CSS, all browsers suddenly began respecting my intended styling. Sigh of relief.

On that note, its worth bringing up the success that browser competition has brought to HTML and CSS rendering standards over the past few years. The push for the fastest and most capable browser has brought a scattered group of browsers a little closer and the result is that we get to enjoy dealing with fewer and fewer bugs.

While your average Joe web developer may have dug around for hours for this issue to no avail, I must say… I thought it was nice to face such a subtle issue rather than being forced to use some crazy IE specific hacks like for legacy IE.

[How to] Create a bootable USB stick on OS X

A couple of days ago I decided to reinstall my operating system since it was failing. I quickly realized that the only functional system that I had at the time was my MacBook Pro. After a bit of Googling, I came up with a pretty straightforward guide, but they really could have formated it to make it easier to follow.

I’m going to run you through the same steps and you should be able to use this guide to create a bootable USB stick for Windows, Ubuntu, Fedora, etc.

The Guide

  1. Download the disc image that you want to use. (I’ll use Ubuntu in my example, but you can use Windows or whatever you’ve downloaded.)
  2. Open the Terminal (in /Applications/Utilities/ or query Terminal in Spotlight).
  3. Convert the .iso file to .img using the convert option of hdiutil as shown below (replace the paths and image names to suite your needs):

    hdiutil convert -format UDRW -o ~/path/to/target.img ~/path/to/ubuntu.iso

    Note: OS X tends to put the .dmg ending on the output file automatically, creating the file target.img.dmg. I’ve always removed the .dmg extension.

  4. Run diskutil list to get the current list of devices.

    diskutil list

  5. Insert your flash media.
  6. Run diskutil list again and determine the device node assigned to your flash media (e.g. /dev/disk2).

    diskutil list

  7. Run diskutil unmountDisk /dev/diskN (replace N with the disk number from the last command; in the previous example, N would be 2).

    diskutil unmountDisk /dev/diskN

  8. Execute sudo dd if=/path/to/downloaded.img of=/dev/rdiskN bs=1m (replace /path/to/downloaded.img with the path where the image file is located; for example, ./ubuntu.imgor ./ubuntu.dmg).

    sudo dd if=/path/to/downloaded.img of=/dev/rdiskN bs=1m

    Using /dev/rdisk instead of /dev/disk may be faster
    If you see the error dd: Invalid number ’1m’, you are using GNU dd. Use the same command but replace bs=1m with bs=1M
    If you see the error dd: /dev/diskN: Resource busy, make sure the disk is not in use. Start the ‘Disk Utility.app’ and unmount (don’t eject) the drive.

  9. Run diskutil eject /dev/diskN and remove your flash media when the command completes (replace N with the disk number).

    diskutil eject /dev/diskN

  10. Restart your PC and enter the boot options to choose the USB stick. If you’re installing to your Mac, restart and press alt/option key while the Mac is restarting to choose the USB stick.

If you’ve made it this far, then you should be well on your way to installing a new operating system. Good luck!

Create a Bootable Windows 7 x64 Install Flash Drive from 32-bit Windows

Creating a bootable Windows 7 x64 flash drive from within a 32-bit install of Windows is not as straight forward as it may seem. I recently had to go through this process myself, so I’ll document the steps below.

Things you’ll need

  1. Windows 7 x64 disc image
  2. Windows 7 USB/DVD Download Tool
  3. 32-bit bootsect.exe

Create the installer

  1. Install the Windows 7 USB/DVD Download Tool.
  2. Extract the 32-bit bootsect.exe file to the directory that the Windows 7 USB/DVD Download Tool was installed to. This is usually something like “C:\Users\username\AppData\Local\Apps\Windows 7 USB DVD Download Tool“.
  3. Run the Windows 7 USB/DVD Download Tool and select your Windows 7 disc image. Follow the remaining steps in this tool and your image should be created successfully!

If you’ve followed these steps and your flash installer was created successfully then your next step is to, of course, install Windows 7! Don’t forget to change your boot options to load from USB!

This information is scattered on the web and slightly detailed on the Windows 7 USB/DVD Download Tool page, but I was not able to find a guide laid out as simplified as the one I’ve provided above. In most tutorials they suggest that you download the entire 32-bit iso in order to get the 32-bit bootsect.exe application, but I’ve made that step a lot less troublesome. Hopefully this has helped you!

Nvidia patches a bug I’ve waited 9 months for…

I’ve been following an Nvidia bug that’s been affecting me for a while now and am happy to say that its apparently been fixed! I say apparently, because I’ve not been around my Linux box for several days (due to the holidays) and haven’t had a chance to confirm for myself.

If you have an Nvidia card, especially the 7300le model like I have, and have had difficulties using Unity 3D with the proprietary drivers, then you may have experienced this bug: [nvidia, 7300, 7400] display freeze when using unity desktop

Nvidia has just released an update which resolves this issue and it can easily be installed right away!

Release highlights since 275.36:

  • Fixed a bug that would cause Firefox to abort on pages with Flash when layers acceleration was force-enabled on Linux and Solaris.
  • Fixed a bug that could cause display devices on a secondary GPU to get swapped between X screens when restarting the X server.
  • Fixed a regression that caused blank/white windows when exhausting video memory on GeForce 6 and 7 series GPUs while using composited desktops.
  • Fixed a bug that caused a crash when glDrawArrays was used with a non-VBO vertex attribute array to draw on a Xinerama screen other than screen 0 using an indirect GLX context.

The 275.43 NVIDIA Accelerated Linux Graphics Driver Set for Linux/x86 is available for download via FTP.

The 275.43 NVIDIA Accelerated Linux Graphics Driver Set for Linux/x86_64 is available for download via FTP.

 

Please see the README (x86 / x86_64) for more information about this release.

 

Please note: This NVIDIA Linux graphics driver release supports GeForce 6xxx and newer NVIDIA GPUs, GeForce4 and older GPUs are supported through the 96.43.xx and 71.86.xx NVIDIA legacy graphics drivers. GeForce FX GPUs are supported through the 173.14.xx NVIDIA legacy graphics drivers.

 

Please also note: If you encounter any problems with the 275.43 NVIDIA Linux graphics driver release, please start a new thread and include a detailed description of the problem, reproduction steps and generate/attach an nvidia-bug-report.log.gz file (please see http://www.nvnews.net/vbulletin/showthread.php?t=46678 for details).

If you’re seeing the same problem and would like to test the update, there are a few specific instructions that you may (or may not) need to follow, posted here.

Submitting Anonymous Usage Statistics

Banshee Media Player Usage Statistics

Being a software developer myself, I tend to pay attention to application functionality and options a little more than the average end user. I’ve noticed that over the last few years when I encounter an option to ‘submit anonymous usage statistics’ I gladly and immediately enable it.

Knowing that you can gain valuable information about the way your end users are using your product, it makes sense for a software developer to include this option and frankly I’m baffled that its not available in most all applications.

I’d like to use this post for two reasons:

  1. To encourage you and others to consider enabling this option in order for developers to get the accurate information that they need to make their product even better!
  2. To maintain a list of these options in various applications that I stumble upon so others are aware.

As I gradually increase the number of applications, feel free to point out applications that I’ve missed and I’ll add them to the list!

Application List:

 

Adium

 

Banshee Media Player

 

Eclipse

 

Google Chrome

 

Google Drive

 

Google Music Manager

 

Opera

 

Ubuntu Software Sources

 

Google Music Manager

 

 

Using Synergy with Mac and Ubuntu

Ubuntu Linux Hostname from Terminal

This is just a quick guide for those of you who also use both Mac and Ubuntu (or really any flavor of Linux) side by side. If you’re not already familiar with Synergy, it’s a small application that connects your mouse and keyboard to one or more machines for a more continuous experience.

Mac and Linux use a graphical front-end for Synergy known as QuickSynergy. Here’s how to get it configured for use between Mac and Ubuntu…

Hostnames

You can find the hostnames to use simply by opening a Terminal window, or if you’re unsure still, simply type hostname and press enter. ;)

If you used the hostname command in Ubuntu, you probably noticed that the “.local” part is not printed out, but it is necessary when dealing with Mac OS X.

Connecting the Two

After selecting the system you’d like to share, configure the Use or Share tab as necessary similar to the examples below:

After configuring Synergy/QuickSynergy you’re all set to start making your life easier!

Unity Opera!

Unity Opera Tab Count

With Unity in the recent spot light and a little free time on my hands, I decided it was time to dabble with the Launcher API. What better combination that my two favorite pieces of software: Unity in Ubuntu and Opera!

With my Unity Opera script, you’ll be able to get extra functionality for Opera by simply downloading a script and adding it to your Startup Applications list. No technical modifications necessary!

The Launcher API provides four features at the moment: Count, Progress, Urgency, Quicklists.

At the moment I’m only able to implement functionality for three of these, with the exception being Progress. In its current implementation, Unity Opera has the following features:

Count

The total number of tabs you have open appears on the Launcher icon and is updated in real time as you open and close tabs.

One item to note here is that Opera’s Private tabs are not included in this tab count. Since information about these tabs and their contents are not stored anywhere on your computer, Unity Opera has no way of discovering them.

Progress

At this point in time, the progress functionality for this script is not available. Until I find a way to programmatically determine download progress in Opera, I will not be able to implement this.

If you have any information regarding a way to implement this feature then please let me know!

Urgency

When browsing the net, not every link you click on is from inside the web browser. Sometimes you click a link from an instant message, mail client, Gwibber, etc. This is where urgency comes into play.

Typically clicking these links automatically opens the tab in your browser, but it doesn’t always pull you’re browser into focus. When this happens, you may not know which browser the link opened in or if clicking it was even successful.

When Opera is not in focus and a new tab is opened, the Opera icon in the Launcher now enters urgency mode and wiggles onces. An urgency highlight is also applied to the icon and a small attention reminder in the upper left corner until you focus Opera again (this clears the urgency setting).

Quicklists

Previously I shared a tip on how to customize your Quicklists for Opera. That method meant that you had to manually open and edit the desktop file.

This is no longer the case, as these features are already built into Unity Opera.

On top of that, your Speed Dial items are also appended to the Quicklist, making your life that much easier! ;)

If you use Opera’s built in Mail client, also known as M2, then you will see an Opera for Mail, which is intended to open M2 directly. At the moment, this feature doesn’t work as intended, but hopefully in due time it will.

Download Unity Opera

Unity Opera is written in python and can easily be updated and maintained. I suggest you save and extract it to your Home directory and use it there, but you are free to place it anywhere you wish.

Download

Running Unity Opera

You can run Unity Opera in one of two ways:

1. The easiest way in my opinion is to simply add it to your Startup Applications.

To do this simply open your dash and search for ‘Startup Applications‘. Once there, click ‘Add‘ and fill in the blanks!

To run Unity Opera on startup, I place the script in my home folder. You can place it where ever you wish, but if you pick a place other than your home folder then you will need to provide a full path the script in your startup command.

An example of what I use is as follows:

python unity-opera.py

2. The other option is to open a terminal when you want to use this script and run the command above.

Options

This script has several options. For help and more information type:

python unity-opera.py –help

This script accepts two optional args:

1. Opera Channel: This is used for setting Unity Opera to run against regular Opera and the new Opera Next channel. By default, if you exclude this arg, Opera is set as the browser to run against. Examples of this command include:

python unity-opera.py opera

python unity-opera.py opera-next

2. Enable features: This is used to enable specific features. You can enable only basic quicklists [q], quicklists with Speed Dial entries [qs], tab count [c], urgency notification [u], and progress [p].

As mentioned before, progress is not functional at the moment, but I’ve built the script with this feature ready to include as soon as I find a way. ;)

This second argument requires the use of the first argument. Examples of this command include:

python unity-opera.py opera -qs

python unity-opera.py opera-next -qsu

Troubleshooting

If you experience trouble with this script, please try running it from a terminal to see if there are any errors output to the console. If so, copy and paste these in the comments below and I will take a look at them.

Quicklists for Opera in Unity

Opera Extended Unity Menu

Thanks goes to Jorge Castro and a recent post of his about Quicklists in Unity.

After reading his post and seeing how easy it was to add new Quicklist entries, I decided to give it a go with Opera.

As you can see, my efforts were successful, but there are many more list items you could add to customize Opera’s Quicklist to suit your needs.

Get It for Yourself

If you’re using Ubuntu 11.04 with Unity and want to customize this menu for yourself then just follow follow these simple steps.

1. Open a terminal and type the following (and enter your password when prompted):
sudo gedit /usr/share/applications/opera-browser.desktop

2. Scroll down to the bottom of this open file and paste the following:
X-Ayatana-Desktop-Shortcuts=NewTab;NewPrivateTab;NewWindow;Mail;

[NewTab Shortcut Group]
Name=New Tab
Exec=opera -newtab
TargetEnvironment=Unity

[NewPrivateTab Shortcut Group]
Name=New Private Tab
Exec=opera -newprivatetab
TargetEnvironment=Unity

[NewWindow Shortcut Group]
Name=New Window
Exec=opera -newwindow
TargetEnvironment=Unity

[Mail Shortcut Group]
Name=Mail
Exec=opera -mail
TargetEnvironment=Unity

3. Save and close the text editor. You may need to restart Unity or your computer before changes take effect.

Customize your Quicklist

If you’d like to add more items to the Quicklist, simply add a shortcut name for it in “X-Ayatana-Desktop-Shortcuts" and create a "Shortcut Group" for it.

A couple of things that I considered adding were Gmail and Google Reader so that they simply open in new tabs. I’m sure you can find other useful shortcuts to add or maybe even more Opera command line options!

Remove your Changes

If you don’t like the Quicklist items that you’ve added, all you need to do is open the opera-browser.desktop file and remove the lines that were added. Save, close and voila.

Conclusion

Quicklists are great, but they would be more useful with Opera if we were able to select from a list of open or recent tabs.

The new tab and window shortcuts that I’ve added are enough for me at the moment, but I would really love to see them added by default in the near future!

How to setup and use Tor Anonymity in Ubuntu

tor-vidalia-control-panel-ubuntu-11-04

Just before the new year, I saw a news article by Wired that highlighted flaws found in the Tor Anonymity Network. I had never used Tor, but I knew what it was, the benefits it could provide, and a bit about how it worked.

With a little free time on my hands I decided to set it up and see what all the fuss was about. At the time I was installing the Tor components in OS X, but I was curious about installing it in Ubuntu and the resources and instructions that I came across were not as straight forward as they could have been. That is where this post comes it, to provide a simple step by step guide with no fuss.

What is Tor?

This is how Wikipedia explains Tor:

Tor is a system intended to enable online anonymity, composed of client software and a network of servers which can hide information about users’ locations and other factors which might identify them. Use of this system makes it more difficult to trace internet traffic to the user, including visits to Web sites, online posts, instant messages, and other communication forms. It is intended to protect users’ personal freedom, privacy, and ability to conduct confidential business, by keeping their internet activities from being monitored.

What does it look like?

Tor itself doesn’t have a graphical user interface (GUI), but there is an application known as Vidalia which provides a nice and simple user interface for controlling all of your Tor needs.

When installing Tor in Ubuntu, you will need to install 3 components: Tor, Polipo, and Vidalia. Tor and Vidalia should now be obvious to you (since I’ve explained that Vidalia provides a GUI to Tor).

Again, according to Wikipedia here is what Polipo is:

Polipo is a fast and lightweight, forwarding and caching proxy server, SOCKS proxy and computer software daemon.

Install Tor in Ubuntu

This is really quite simple and I could easily provide a simple bash script to automate all of this for you, but that would mean that I would have to maintain it and that you wouldn’t learn anything. ;)

For simplicity, I will write this guide assuming you are using Ubuntu 10.10, aka Maverick. If you’re using a different version, make sure you change the necessary bits below.

  1. Open “Software Sources,” select the “Other Software” tab, click the “Add” button at the bottom and paste the following:

    deb http://deb.torproject.org/torproject.org maverick main

    Click “Add Source,” then click Close. When it asks if you want to Reload, click yes and ignore any errors for now.

  2. Open a Terminal and add the Tor Repository keys and update Apt:

    gpg –keyserver keys.gnupg.net –recv 886DDD89
    gpg –export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
    sudo apt-get update

  3. Install Tor, Polipo, and Vidalia:

    sudo apt-get install tor tor-geoipdb polipo vidalia -y

    When prompted during the installation of Vidalia, select the option to permanently replace (or however it is worded).

  4. Download a pre-made config file for Polipo:

    wget https://gitweb.torproject.org/torbrowser.git/blob_plain/HEAD:/build-scripts/config/polipo.conf
    sudo mv /etc/polipo/config /etc/polipo/config.bak
    sudo mv polipo.conf /etc/polipo/config

  5. Now Stop and Restart both Tor and Polipo for safe measure:

    sudo /etc/init.d/tor stop
    sudo /etc/init.d/polipo stop
    sudo /etc/init.d/polipo start

    Open the application Vidalia when you would like to connect to the Tor network. If you want it on by default, you can always set Vidalia to autostart with your computer.

  6. All thats left is to configure your Applications to use the Tor proxies! If you don’t adjust the network settings of your applications to use the Tor proxy settings then you’re not using Tor at all. You can confirm that Tor is indeed working by visiting the Tor detector page.

If you run into issues for any reason, check back through the steps listed above. If that still doesn’t fix them, you might check the Community Ubuntu Documentation on Tor page or the official Tor for Linux/BSD/Unix page.

Configuring applications to use the Tor proxies

There are 2 types of configurations for Tor:

  1. HTTP or HTTPS – Typically used for web browsers such as Opera, Firefox, Safari, Google Chrome, etc.

    Host: 127.0.0.1
    Port: 8118

  2. Sockets – Typcially used for instant messaging applications such as Trillian, Digsby, MSN, AOL, Empathy, Pidgin, etc.

    Host: 127.0.0.1
    Port: 9050

Nearly any application that allows you to adjust network settings by using proxies can make use of the Tor Anonymity Network. Configuring your application of choice is a matter of selection to use HTTP or Sockets.

If you’re unsure, use trial and error. ;)

A great note that I came across on the Community Ubuntu Documentation page for Tor that I think everyone should read carefully before using Tor is as follows:

What’s the use of having Tor and Privoxy setup without enabling your new anonymous proxy in your common web applications? At this time Tor only supports HTTP and HTTPS traffic, but still recommends using Tor in your browser’s proxy settings for all protocols as a hidden image link can give away your IP address if linked to an image on an FTP site.

Conclusion

Hopefully by this point you’ve successfully configured Tor for all of your anonymity needs. Will Tor works great, it only works great if you’ve configured it correctly.

Some Tor connections may be slower than others. If you’re experiencing a connection that is simply too slow for your needs or if you need a new ip address so you can get that file from RapidShare without having to wait for an hour, simply open Vidalia Control Panel and click “Use a New Identity.”

Remember that Tor can be used for Windows and Mac, and is more straightforward to install for them as well.

While there have been a few flaws exposed, as mentioned before, I would tend to think the risk of being identified over Tor is very low since the attacks would have to occur on the same network that you’re connected to. I typically only use Tor at public internet access points (which is where these attacks would be most likely to occur), but it can be very handy in many situations and will likely continue to be on the list of my apps to install for a long long time.