(These instructions are for the debian6-13-04-2012 image but they should be applicable to later versions as well. YMMV)

Step 1 - Edit your APT Sources

Before we start, you should edit /etc/apt/sources.list and include the ‘non-free’ section of the repositories since firmware blobs for wireless adapters are usually ‘non-free’:

$ sudo nano /etc/apt/sources.list

Change:

deb http://ftp.uk.debian.org/debian/ squeeze main

to

deb http://ftp.uk.debian.org/debian/ squeeze main non-free

and issue:

$ sudo apt-get update

to refresh the package database.

Step 2 - Figure out which chipset you have

Now, plug your USB wifi adapter to one of the ports and issue: lsusb. You should see something along the lines of:

$ lsusb

...
Bus 001 Device 004: ID 0ace:1215 ZyDAS ZD1211B 802.11g
...

Okay, it looks like the chipset we have here is ‘zd1211’ (Have a look at http://wiki.debian.org/WiFi for a list of supported chipsets)

Let’s see if there are any firmware packages we can install to get this up and running:

$ apt-cache search zd1211

zd1211-firmware - Firmware images for the zd1211rw wireless driver

Sweet, let’s install that:

$ sudo apt-get install zd1211-firmware

We should be good to go now. Unplug the adapter, plug it back in again and have a look at the output of lsmod:

$ lsmod

Module   Size   Used by
arc      4764   2
zd1211rw 40444  0
mac80211 171628 1 zd1211rw
cfg80211 123084 2 zd1211rw,mac80211
fuse     49036  1

You should see mention of zd1211.

dmesg should also give you an indication whether things are loaded or not:

$ dmesg

...
usb 1-1.2: new high speed USB device number 4 using dwc_otg
usb 1-1.2: New USB device found, idVendor=0ace, idProduct=1215
usb 1-1.2: New USB device strings: Mfr=16, Product=32, SerialNumber=0
usb 1-1.2: Product: USB2.0 WLAN
usb 1-1.2: Manufacturer: ZyDAS
cfg80211: Calling CRDA to update world regulatory domain
usb 1-1.2: reset high speed USB device number 4 using dwc_otg
ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'
zd1211rw 1-1.2:1.0: phy0
usbcore: registered new interface driver zd1211rw
zd1211rw 1-1.2:1.0: firmware version 4725
zd1211rw 1-1.2:1.0: zd1211b chip 0ace:1215 v4810 high 00-1a-ee UW2453_RF pa0 -7---
...

Awesome, looks like the adapter is up and running! To see which networks are available, do:

$ iwlist wlan0 scan

…which should give you a list of wireless networks around you.

Step 3 - Configure adapter and WPA settings

One final bit left to do now: configuring our adapter. Before that though, we should make sure that you have wpasupplicant package installed since you’ll probably want to connect to a WPA secured network:

$ sudo apt-get install wpasupplicant

After that’s done, create a configuration file for it:

$ sudo nano /etc/wpa.conf

network={
ssid="YOUR-SSID"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="WPA-PASSWORD"
}

And reference this in /etc/network/interfaces:

$ sudo nano /etc/network/interfaces

# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.

auto lo

iface lo inet loopback
iface eth0 inet dhcp

auto wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa.conf

Step 4 - Conclusion

Restart your networking subsystem with:

$ sudo /etc/init.d/networking restart

If you have DHCP enabled on your network, you should see something along the lines of:

Reconfiguring network interfaces...Internet Systems Consortium DHCP Client 4.1.1-P1
Copyright 2004-2010 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/wlan0/00:1a:ee:00:b4:12
Sending on LPF/wlan0/00:1a:ee:00:b4:12
Sending on Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 7
DHCPOFFER from 192.168.0.1
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPACK from 192.168.0.1
bound to 192.168.0.103 -- renewal in 40349 seconds.
done.

(If not, you will have to edit /etc/network/interfaces and manually specify your IP address/gateway etc.)

You can also issue dmesg again to see what’s happening under the hood:

$ dmesg

...
wlan0: authenticate with 00:26:f2:3f:XX:XX (try 1)
wlan0: authenticated
wlan0: associate with 00:26:f2:3f:XX:XX (try 1)
wlan0: RX AssocResp from 00:26:f2:3f:XX:XX (capab=0x431 status=0 aid=3)
wlan0: associated

Which means you should now be connected!

If it doesn’t work, well, have you tried turning it off and on again? :)