To set up wifi (WPA/WPA2 Only) on the Pi, I was able to get the following working with my setup. Other instructions (including the ones adding the directives to /etc/network/interfaces) didn’t work for me.

I just installed Raspbian on a Pi today (2015-01-02), so these instructions should be current. My /etc/network/interfaces file already had the following in it (if yours doesn’t, then put these lines in so it looks the same):

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Then, edit /etc/wpa_supplicant/wpa_supplicant.conf and add the following onto the end of the file:

network={
    ssid="YourSSIDHere"
    proto=RSN
    key_mgmt=WPA-PSK
    pairwise=CCMP TKIP
    group=CCMP TKIP
    psk="YourPasswordHere"
}

Then, restart your network interface. I personally use:

sudo ifdown wlan0
sudo ifup wlan0

It should take a second or two to finish (and mine spits errors). You can check and make sure you have an IP by running ifconfig.

Note: You can also set the pi to have a static IP by changing the “iface default inet dhcp” line to “iface default inet static” and adding the proper information below. See my other post Ubuntu 14.04+: Changing to Static IP for that information.

Done!

Thanks to: http://kerneldriver.wordpress.com/2012/10/21/configuring-wpa2-using-wpa_supplicant-on-the-raspberry-pi/