Install Raspbian and configure Wi-fi without a monitor or keyboard
I’ve just bought a Raspberry Pi and not having access to an extra monitor, keyboard or mouse I had to make do with just a router and an ethernet cable. I realize you could already piece most of this together from other places on the internet, but I wanted to document the way I did it. Having called a vote the motion passed with one in favor and none against so online it goes.
- First thing’s first and you’ll have to get a suitable image, I went with the Raspbian Wheezy and downloaded the torrent through Raspberry Pi Website Downloads. Be a pal and seed it for a while.
sha1sum 20XX-XX-XX-wheezy-raspbian.zipand make sure it matches the one on the download page.
unzip 20XX-XX-XX-wheezy-raspbian.zipto extract the image.
- Plug your SD card in and run
df -hto find its name. In my case it was
- Unmount the right one with umount
- Make sure you have the SD card name right and that you’ve unmounted it and run
sudo dd bs=4M if=20XX-XX-XX-wheezy-raspbian.img of=/dev/XXX. This step might take a few minutes without any feedback so be patient.
sudo syncto ensure that everything in memory was written to the card, remove it, and plug it into your Raspberry Pi.
- Get an ethernet cable with one of the ends plugged into a functioning router and plug the other end into the Raspberry Pi. Power on the Raspberry Pi with an adequate power source.
- After waiting for a minute go to your router page which in my case was http://192.168.1.254/. Find a page where you can check which devices are currently connected to the router and from that list get the IP that was assigned to the Raspberry Pi, it should be under the name “raspberrypi”.
ssh 192.168.0.XX -l piwith the right IP address from the previous step. When prompted for the password, type in “raspberry”.
sudo raspi-configand select the update option. Mess around with other configurations as you please. Be careful with the overclocking and push “finish” when you’re done
- After the Raspberry Pi reboots run
ssh 192.168.0.XX -l piagain.
- Update your package list with
sudo apt-get update && sudo apt-get upgrade.
You now have a working installation running. If you wish to have a wireless internet connection there’s a couple more things you might want to do.
- Type sudo
nano /etc/network/interfacesin and paste this into the file (Ctrl+Shift+V should work):
iface lo inet loopback
iface eth0 inet dhcp
iface wlan0 inet dhcp
- To generate the right psk key run
wpa_passphrase yourssid yourpassword. Type
sudo nano /etc/wpa_supplicant/wpa_supplicant.confin and paste something like this into the file.
- As an alternative, you might want to try and install a visual tool to connect to networks. Run
sudo apt-get install wicd-cursesand run it. It’s not as messy as configuration files and if you don’t know the quirks of each security setting it’s a lot easier. I’ve run into some problems with WEP on wicd-curses and that’s why I’ve opted to document the configuration files though.
- After rebooting or running
sudo /etc/init.d/networking restartyou can unplug the ethernet cable and your Raspberry Pi should automatically connect to your router.
Now you could go into your router page and find which IP was assigned to the Raspberry Pi each time you want to connect or you could force it to choose a static IP. I chose a different option which was to use Avahi. Avahi makes the Raspberry Pi advertise itself to the network as “raspberrypi.local” so you can always use this alias to ssh into it, whatever IP it is assigned by the router. Pretty neat.
sudo apt-get install avahi-daemonand then
sudo insserv avahi-daemonon the Pi.
- Create a config file with sudo nano /etc/avahi/services/multiple.service` and paste in this.
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
- Restart the daemon with
sudo /etc/init.d/avahi-daemon restartand disconnect your ssh session.
- You can now log into the Pi with
ssh [email protected]or alternatively change the hostname to something more unique.
- To change the hostname go to
sudo nano /etc/hostnameand insert whatever name you wish. Then on to
sudo nano /etc/hostsand replace “raspberrypi” with the name you chose earlier and finally run
sudo /etc/init.d/hostname.sh startto enable the changes.