Setting up WiFi connection
Start by booting the Raspberry Pi, connected to a display and a keyboard. Open up the terminal and edit the network interfaces file:
$ sudo nano /etc/network/interfaces
This file contains all known network interfaces, it'll probably have a line or two in there already.
Change the first line (or add it if it's not there) to:
Then at the bottom of the file, add these lines telling the Raspberry Pi to allow wlan as a network connection method and use the
/etc/wpa_supplicant/wpa_supplicant.conf as your configuration file.
iface wlan0 inet dhcp
iface default inet dhcp
(ctrl-X, then type Y to quit and save)
The next step is to create this configuration file.
Configuring WiFi connection
Open up the wpa_supplicant.conf file in the editor.
$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Again, some lines might already be present, just add the following.
The other parameters are network specific, I can't tell you what you need. If you boot Raspbian to desktop, you can launc the wpa_gui (WiFi config) application and click 'Scan'. You'll find a list that has your network too with all flags you need. To do this on a RPi A you'll have to disconnect your keyboard and connect your dongle once the scanning list is open.
protocould be either
key_mgmtcould be either
WPA-PSK(most probably) or
pairwisecould be either
auth_algis most probably
OPEN, other options are
Make sure it works
Reboot the Raspberry Pi and it should connect to the wireless network. If it doesn't, repeat above steps or get help from an adult.
A static IP
Since the goal of this tutorial is to be able to work with the RPi without external keyboard or display, you want to be ssh into it. The best way is to make sure it'll always have a static IP on your network.
Doing so is simple. Open the /etc/network/interfaces file again and add the following changes: Change iface wlan0 inet dhcp into iface wlan0 inet static. This changes the wlan0 interface from DHCP to static. Add the following lines before the wpa-conf line:
address 192.168.1.155 # Static IP you want
gateway 192.168.1.1 # IP of your router
The Raspberry Pi will still be able to connect to the internet.
With these changes you'll be able to always connect to your Raspberry Pi over your wireless network via ssh at the same, static IP. This means you can disconnect keyboard, mouse and display and have it plugged in a wall socket, anywhere, taking almost no space.
As an overview, my interfaces- and wpa_supplicant-files:
iface lo inet loopback
iface eth0 inet dhcp
iface wlan0 inet static
iface default inet dhcp