Setup a Headless Raspberry Pi with Raspbian Jessie on OS X

To celebrate Halloween I’ve decided to put together a guide that will show you how to install Raspbian Jessie, the (as of this writing) most current version of the Debian operating system for the Raspberry Pi. The biggest difference between this guide and the hundreds if not thousands of other guides out there on the web is that this guide will teach you to set up your Raspberry Pi without a dedicated monitor or TV (or headless mode). You’ll control everything from another computer that will access the RPi over the network, and it’s fairly straightforward. In my opinion this is the easiest way to set up a Raspberry Pi, and it’s coincidentally very similar to how much larger servers are configured in a data center environment.

I’ve taken the liberty of testing this procedure on all of the following models of the Raspberry Pi, so your mileage should not vary, as these are the most commonly found variants of the RPi:

  • Raspberry Pi Model B w/ 256MB RAM (2012)
  • Raspberry Pi Model B w/ 512MB RAM (2014)
  • Raspberry Pi 2 Model B w/ 1GB RAM (2015)
  • Raspberry Pi 3 Model B w/ 1GB RAM (2016)

The Goal

By the time we’re finished, we’ll have a network-accessible Raspberry Pi running Raspian Jessie.

Downloading Raspbian Jessie

To prepare, we’ll download the image that we’ll then install to the SD card which will be inserted into the Raspberry Pi. If you’re comfortable downloading torrents, you can use this torrent link to download the .zip quite fast.

If you’re prefer to download it in a more traditional way, you can run the following command from your Mac:

cd ~/Downloads && curl -O

Once we’ve downloaded Raspbian Jessie, we’ll need to unzip it. People have been having a ton of trouble with this producing a cpgz file due to a bug in OS X that prevents OS X from unzipping some files over 4GB. Here’s how to unzip and end up with the intended file, 2015-09-24-raspbian-jessie.img, from the terminal:

tar -xvf

This leaves us with 2015-09-24-raspbian-jessie.img. It should be located at ~/Downloads/2015-09-24-raspbian-jessie.img. Now it’s time to copy this image to the SD card.

Preparing the SD Card

The first step in preparing the SD card is to insert it into the Mac. Some Macs have a slot for this, others don’t (in this case an SD to USB adapter will do the trick).

Once the SD card is inserted, we can open a terminal and run the df -h command. This command will list all mounted disks in the Mac, including the newly inserted SD card, and should produce something similar to the following output:

$ df -h
Filesystem      Size   Used  Avail Capacity  iused    ifree %iused  Mounted on
/dev/disk1     465Gi  231Gi  234Gi    50% 60591774 61251936   50%   /
devfs          187Ki  187Ki    0Bi   100%      648        0  100%   /dev
map -hosts       0Bi    0Bi    0Bi   100%        0        0  100%   /net
map auto_home    0Bi    0Bi    0Bi   100%        0        0  100%   /home
/dev/disk2s1     0Mi    0Mi   32Gi     0%        0        0  100%   /Volumes/UNTITLED

Notice /Volumes/UNTITLED here is showing up as /dev/disk2s1. This filesystem identifier will be different on every system, so it’s important not to just copy and paste the identifier shown in the example above. This is the SD card. The next step is to unmount it using the sudo diskutil unmount /dev/disk2s1 command, which will prompt for our OS X password and produce output similar to the following:

$ sudo diskutil unmount /dev/disk2s1
Volume boot on disk2s1 unmounted

Now that the disk is unmounted, we can use the dd command to copy our Raspbian Jessie image to it. This will look something like the following (and it will take a few minutes to complete, so don’t panic!). Also, notice /dev/rdisk2 is used here instead of /dev/disk2s1. If your disk is labeled something like /dev/disk3s1, you would use /dev/rdisk3 here:

$ sudo dd bs=1m if=~/Downloads/2015-09-24-raspbian-jessie.img of=/dev/rdisk2
4125+0 records in
4125+0 records out
4325376000 bytes transferred in 211.177442 secs (20482188 bytes/sec)

Note: Before continuing, place a file called ssh in the /boot/ directory of the SD card. In our example, it can be accomplished with:

touch /Volumes/boot/ssh

The final step is to eject the SD card. This is more of a figurative action than a literal one, as it won’t actually eject from the Mac. Essentially, this disconnects the SD from the Mac so that it can be safely removed, and it’s done as follows:

sudo diskutil eject /dev/rdisk2
Disk /dev/rdisk2 ejected

The SD card is now prepared for use with the Raspberry Pi. Next, we’ll use it to set up the Raspberry Pi.

Plugging In and Powering Up

At this point we’re ready to start plugging things in. There is an order of operations that we should follow here (power should be last):

  1. Insert the SD card into the Raspberry Pi.
  2. Plug an ethernet cable from the router to the Raspberry Pi.
  3. Plug power (provided via micro USB) into the Raspberry Pi.

Power will be provided as soon as it’s plugged in, and after approximately a minute, the Raspberry Pi will have completely booted up. At this point it should have been automatically assigned an IP from the router, which is probably running DHCP (as most home routers do).

To access the Raspberry Pi, we’ll need to get the IP address it has been assigned. This might be very simple. We can try to run arp -a from our Mac to get a list of devices on our local network, as follows:

$ arp -a
router.smalleycreative.local ( at 4c:8d:79:03:bc:ad on en0 ifscope [ethernet]
raspberrypi.smalleycreative.local ( at b8:27:eb:91:2a:df on en0 ifscope [ethernet]

It is very clear from this output that the Raspberry Pi has an IP address of SSH is running.

Important Note: As of November 2016 SSH no longer starts by default on Raspbian, and so to access it, SSH needs to be enabled. This was done when we put the empty file called ssh, in the /boot/ directory on the SD card using the touch command (as documented above). When the Pi boots, it looks for this file; if it finds it, it enables SSH and then deletes the file.

Given we’ve got SSH enabled, the Pi can be accessed at (the password is raspberry):

$ ssh pi@
The authenticity of host ' (' can't be established.
RSA key fingerprint is 52:16:ad:8a:12:7b:f4:84:1a:8e:3e:0f:e1:a3:3b:5e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (RSA) to the list of known hosts.
pi@'s password:

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Sep 24 15:33:03 2015

At this point it’s time to expand the filesystem. This just ensures that all of the SD card storage is available to the Raspbian OS. To do this, run raspi-config, and select Expand Filesystem:

pi@raspberrypi ~ $ raspi-config

Once this is done, we select Finish, and agree to reboot the Raspberry Pi.

Now What?

At this point it is a good idea to rerun raspi-config to set a user password that is different than the default password of raspberry. Better yet, configure public key authentication, which eschews the use of passwords for key-based authentication, which is much more secure. Official instructions on how to do that are provided over at


One response to “Setup a Headless Raspberry Pi with Raspbian Jessie on OS X”

  1. Karl Avatar

    Thank you! Works like a charm. Only key exchange for ssh and wi-fi left to do.

Leave a Reply

Your email address will not be published. Required fields are marked *