Raspberry Pi 3: headless setup with Mac

Laura Bravo Priegue
5 min readApr 13, 2020

--

I recently got a beautiful Raspberry Pi 3 as a gift, and yesterday I finally decided to set it up. Initially, this looked more challenging than I expected, since I don’t have a monitor, keyboard nor an ethernet port on my MacBook… I basically don’t have any of the elements most tutorials label as essential.

However… I managed!! (my dad helped lol) Since the tutorials I saw were a bit confusing, I thought that I could share what I did to help others in the same situation. So here we go:

  • Copy Raspbian on an SD card

We start by installing the OS Raspbian onto the Raspberry Pi. This proved to be extremely straightforward. I started by inserting an empty SD card onto the SD card reader of my Mac. Make sure the SD card meets the criteria.

For copying the Raspberry OS onto the empty SD I used the Raspberry Pi imager. I downloaded it from the official Raspberry site.

This was like magic. Basically this window popped up:

I chose the Raspbian as my OS and the SD card I had inserted in the Mac. Clicked write… and that’s it!!

Takes a bit to copy but could not be easier.

  • Enable SSH on the Raspberry

Once Raspbian is copied on the SD card you must enable SSH. This is essential for accessing the Pi remotely. Basically the Raspberry will act as a remote device and ssh will allow you to access it using a client from your Mac. More info.

In order to do this you just have to create an empty file (using TextEdit, for example). Name this file ssh. Just that, with no extension! And copy it into the root directory of your SD card (the “boot” partition if you have more than one partition).

Once that is done you can eject the SD and insert it in the Raspberry.

  • Connect Raspberry to your WiFi Router & scan Network IPs

Use an ethernet cable to connect the Raspberry to the WiFi router. Plug in the Raspberry and wait to see one of the LEDs blinking amber (according to my Dad these are the typical LEDs of successful Ethernet connection? tbc). What is for sure is that the Pi is now connected to the internet.

Now, in order to ssh into your Pi all you need is its IP address. To get it, you will need to scan your WiFi network to get the IP addresses of all the devices connected to it (amongst them there should be your Raspberry and your Mac at least). Here is where my Dad helped me, since the IP Scanner is only available for Windows. The recommended option in the Raspberry Pi official page is nmap, but I didn’t like it that much.

I later tried Angry IP Scanner. It is available for Mac. The interface is much uglier than IP Scanner (why is the background black and the font ALSO black?!?!) but it does the job. Make sure you are connected to the same WiFi network as your Pi and press Start. Your Raspberry should appear on the list of connected devices. Copy the IP address of the Pi that should appear on the first column. See an example below:

  • SSH into your Pi & connect it to the WiFi

Now that you know the IP address you should be able to SSH into your Raspberry Pi using the following command: ssh pi@<RP IP ADDRESS>

By default your username is pi and your password raspberry.

Once you are inside the Pi, you have to connect it to the WiFi network. Type sudo raspi-config command to open the configuration interface of the Raspberry.

You can introduce the WiFi name and password within the Network Options of this menu. You can also change your username and password if you want.

Now enter this to start the WiFi adapter:

sudo ip link set wlan0 down

sudo ip link set wlan0 up

Check that you are actually connected to the network by running

iwgetid

This should print the SSID of the network.

  • SSH into your Pi without Ethernet cable

Now your Pi should be connected to the WiFi! Let’s give it a try! Disconnect the Raspberry from the router. Reboot it with the command sudo reboot.

Since it is possible that it changed its IP address already, scan your network again using the IP scanner to get its new address. Then SHH into the Pi using the same command with the new IP address:ssh pi@<RP IP ADDRESS>

--

--

Laura Bravo Priegue

ML Engineer @ SpoonGuru | From Madrid | Always learning ✌🏻