Wpa supplicant

Set wpa_supplicant usage for wlan0
You might also want to change the permissions to ensure that WiFi passwords can't be viewed in plaintext by anyone using the computer:

Using wpa_gui
The simplest way to configure wpa_supplicant is by using its simple (but sufficient for most uses) user interface called wpa_gui. To enable it, build with the the qt4 USE flag enabled.

To allow unprivileged users to control the connection using wpa_gui, add the following at the beginnng of your /etc/wpa_supplicant/wpa_supplicant.conf:

Editing manually
If building with wpa_gui is not desired, wpa_supplicant can be configured manually. This can be fine if the computer does not need to connect to many different access points.

Examples can be found in the wpa_supplicant.conf(5) man page as well as the example wpa_supplicant.conf in the documentation directory (e.g. /usr/share/doc/wpa_supplicant-1.0)

WPA2 with wpa_supplicant
Connecting to any wireless access point serving YourSSID

You can specify which access point you want to connect to using its MAC address, in case there are repeaters in place.