Setting up a Raspberry Pi over Wi-Fi

How to set up and connect to a new Raspberry Pi wirelessly

I’ve just picked up a Raspberry Pi 4 Model B (Pi 4B) which I’m planning to use as a home web server for an IoT project on my local network. Since it’s just going to be a simple web server I didn’t want to go through the hassle of plugging a keyboard, mouse and screen into the Pi to set it up and manage it. Instead I’d prefer to SSH into it over Wi-Fi from my MacBook. Turns out this is quite simple to set up.


  • Raspberry Pi 4 Model B
  • Micro SD card with standard SD card adapter
  • MacBook with SD card slot

Step 1: Flash OS to the SD card

Download the official Rasberry Pi Imager tool. Insert the SD card into your MacBook. Run the imager tool and pick a version of Raspberry Pi OS that you’d like to write to the SD card.

I chose Raspberry Pi OS Lite (formerly Raspbian) for now, it’s a port of the Debian (Linux) operating system but without a desktop environment. So for the most part you can expect to manage this as a Debian instance. You can also choose from Ubuntu Core or Server images or load up your own custom image but I haven’t tested this process with any of these yet.

So select your preferred OS, then select the SD card to write to, and click ‘write’.

After the imager tool has finished writing the OS to the SD card, the SD card might not show up on your desktop any more. To fix this, just remove the SD card from your machine and slot it back in again. It should now appear as a mounted drive called boot.

Step 2: Enable Wi-Fi and SSH

Once you’ve flashed a version of the OS to the SD card you’ll need to add two simple files to the SD card’s root directory.

Add Wi-Fi network details

Create‌ a file called wpa_supplicant.conf in the root directory of the SD card and place the following contents in it:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev


In the text above, change the value for country to your applicable two-letter country code, then replace the ssid and psk values with your Wi-Fi network’s name and password.

Enable SSH

Next create a blank file called ssh in the root directory of the SD card. You can just open up your terminal and paste the following command into it:

$ touch /Volumes/boot/ssh

This will create an empty file called ssh in the root directory of the SD card. Make sure this file does not have a file extension (like .txt for example).

Step 3: Boot up the Rasberry Pi

Safely eject the micro SD card and remove it from your machine. Take the micro SD card out of its adapter and place it into your Raspberry Pi.

If it’s a Pi 4 the micro SD slot is located on the underside of the Pi.

If you have a case for your Pi you’ll need to place your Pi into the case before inserting the micro SD card, there is a small slot at the bottom of the case that allows you to do this. Next, plug in the Pi’s power source and wait for it to boot up, this can take around 90 seconds or so.

Time for the moment of truth…

Open up the terminal and attempt to SSH into the Pi with this command:

$ ssh pi@rasberrypi.local

If you’re prompted about trusting the authenticity of the host just type in ‘yes’ and press enter. You should then be prompted to enter the password for the default ‘pi’ user. The default password for all new Raspberry Pi OS installations is: raspberry

Type in this password and press enter.

…and if all goes well we’re in!

At this point it’s a good time to change the default password which you can do by typing in the passwd command. Then depending on whether you’re planning to make your Pi accessible via the public internet you might want to look into securing your Raspberry Pi further.

And that’s it! This guide is only for Mac currently, as that’s what I was using, but I’ll look at updating it in time with more specific guidance for Windows and any other useful info.

Next I plan to set up a basic web server on the Pi with an API and database, that my IoT project can post sensor readings to.

Anson VanDoren picture

What's your IoT project, and what platform? Just curious :)

Rhett Trickett picture

Hey! I actually ordered an ESP32 after reading about your project! Planning to build a temp & humidity sensor for a medium-sized plant terrarium and have it post sensor readings to an API on the Pi via Wi-Fi. Going to write it in C as I want to learn more of that. Eventually, I'd like to incorporate a LiPo battery with a rough meter, telegram alerts, light & sound sensors and OTA updates.

I've just finished setting up an Express + Postgres API on the Pi, so the next post will be about this. Then for the frontend I was thinking about integrating it with Apple's HomeKit using this. Thought it would be cool to have sensor readings show up in Apple's Home app :)

Anson VanDoren picture

Very cool! I'm working on a new ESP32 project right now too (will write about it here eventually) to control my standing desk. The desk has BLE already, and I can control it out of the box from my phone or computer, but what I really want is a way to control it through MQTT so I can hook it up to my Google Assistant. So trying to learn the BLE spec enough to basically build a gateway device with the ESP32.

Looking forward to reading your writeup when you're done!

Rhett Trickett picture

Nice! Yeah, BLE and MQTT would be interesting to look into. I’ve been thinking about Google Assistant so would be interested to see what you come up with.