This turned out to be dead easy, although it took a bit of futzing around due to my own slowness. The situation arose during an a failed upgrade of my dad’s machine to Ubuntu 10.04 (aka Lucid Lynx). I’m sensing a pattern here; I don’t think there has been an upgrade that has gone smoothly on that machine. To be fair I think there may be problems with just about every component apart from the hard drive, but you think I would realise that upgrading that machine is a Bad Idea. Anyway, the solution:

A combination of wpa_supplicant and wpa_passphrase will do the trick.

  1. Get a root prompt. Either sudo su, or boot to single user (recovery) mode. Just don’t do that, select netroot, then get bored and hit Alt-F1 for a console 1. For some reason, that makes the machine very unhappy and so your wireless hardware probably will complain about device busy in step 2. So don’t do that.
  2. Run iwlist scanning, and check your card can see the wireless network in question
  3. If it can, run wpa_passphrase [your-wireless-network-name] > wpa.conf
    (eg wpa_passphrase pegasus > wpa.conf). The prompt will wait for you to enter a passphrase. Do this and hit enter.
  4. Run wpa_supplicant. Replace wext with the correct wireless driver (which is probably wext, but run wpa_supplicant --help to check) and wlan0 with your wireless interface
  5. wpa_supplicant -Dwext -iwlan0 -c/root/wpa.conf
  6. If that works, you should see text to the effect of “successfully associated”. If not, try again with a different driver, make sure your passphrase is correct, and make sure your wireless interface is working properly.
  7. Hit Ctrl+c, then the up arrow, then add a -B (for background) onto the end of the last command, thus: wpa_supplicant -Dwext -iwlan0 -c/root/wpa.conf -B
  8. Run dhclient -r to release any DHCP leases you have.
  9. Run dhclient wlan0 to get a new IP address. Substitute wlan0 for your wireless interface, of course.

You should now be connected. This is a handy trick for any Linux user unaccustomed to connecting to wireless networks from the command line – let’s face it, network-manager has spoiled us rotten. But when an upgrade fails and won’t leave you with a functioning graphics driver (grr) and you need some packages, this is the way to do it.