Raspberry Pi is a fun little “computer” that is an expandable hardware board with un-ending possibilities for hacking. The one downside is it can be tricky to get started if you don’t have an extra keyboard and mouse hanging around. The following tutorial makes it reasonably easy to set up your Raspberry Pi without a keyboard and mouse. All you need is a Raspberry Pi with a Wifi Adapter and a router with an available ethernet port.

From there, it’s a two step process:

  1. Install Unix on the SD Card
  2. Configure the Raspberry Pi’s Wifi

Let’s take those one at a time.

Install Unix

Your Raspberry Pi comes with a SD card. We’ll install Raspbian, a special Raspberry Pi flavor of Debian, on that card. I use a Mac, so that’s what these instructions cover.

  1. Insert your SD Card into your Mac.
  2. Open up Disk Utility on your Mac.
  3. Select the SD Card in the list at left.
  4. Make sure the format is MS-DOS, give it a name, and then click Erase. Confirm that you want to Erase.

Now open up terminal and run the following commands to install Raspbian, a Debian-based OS designed for use on the Raspberry Pi.

wget http://downloads.raspberrypi.org/raspbian_latest
tar -xzvf raspbian_latest # hit enter after this twice
diskutil list
diskutil unmountdisk /dev/disk2 # this needs to be the correct disk to your SD Card
sudo dd if=2014-01-07-wheezy-raspbian.img of=/dev/disk2 bs=2m # this needs to be the correct disk to your SD Card that you just unmounted

This can take up to 30 minutes. The dd command does not have a verbose mode to show you progress. Be patient. Go for a walk and a coffee. On completion, you will get a confirmation.

Configure Wifi

With Raspbian installed, you’re ready to configure WiFi on your Raspberry Pi. To do this, we’ll first need to connect it to your network over ethernet.

    1. Insert the SD Card (with Raspbian now on it) into your Raspberry Pi
    2. Plug your Raspberry Pi into your router with an ethernet cable.
      photo 2
    3. Find the Ip address of the Pi–I use nmap for network discovery. You can also look at your router’s device table.

      nmap -sn
      Note the IP Address of the Raspberry Pi. We will use this with a default Ansible script to setup Wifi.

(If you aren’t familiar with Ansible, Yamil wrote a post on Using Ansible with Digital Ocean. The gist of what you need is:)

  • Install Ansible using Python’s package manager, pip:

    sudo pip install ansible
  • Clone my Github repo containing example Ansible settings for Raspberry Pi:

    git clone https://github.com/scottmotte/ansible-pi.git
    cd ansible-pi
    cp hosts.example hosts
    cp wpa_supplicant.conf.example wpa_supplicant.conf
  • Edit the wpa_supplicant.conf and hosts files with proper credentials.
  • Finally, push your changes up to your Raspberry Pi using ansible:

    ansible-playbook playbook.yml -i hosts --ask-pass --sudo -c paramiko

(The default password is ‘raspberry’)

That’s it. Now you can unplug the ethernet cord and the Raspberry Pi will work over Wifi. Give it some time to make the connection. SSH in and build out your Pi as you wish.

Hacker in LA. I believe the future is bright. It's up to us to build it - as programmers we get a big say. Follow me on twitter @motdotla.