Start with a Raspberry Pi booted from a freshly downloaded [Raspbian image][raspbian] (2015-02-16-raspbian-wheezy as of this writing). For wifi, I'm using an [Edimax EW-7811Un Wifi USB adapter][edimax] which was $10 on Amazon. I wrote this while running headless and connected via Ethernet, but the same commands will work when connected to a TV with a keyboard and mouse.
If configuring via SSH, try discovering the Raspberry Pi's IP address by running arp -a
, though sometimes that table takes a while to populate. Otherwise just check the router's DHCP table.
Once you have a terminal on the Raspberry Pi, generate the necessary WPA2 pre-shared key with this [WPA Supplicant][] command:
$ wpa_passphrase your_wifi_ssid your_wifi_password
That returns something like this: