Configuring a Headless Raspberry Pi 4 with macOS
Table of Contents
Preparing the MicroSD Card
I personally use a piece of software called balenaEtcher, but you can also use Raspberry Pi’s own Imager. Raspberry Pi Imager includes the option to browse compatible operating systems and download them directly within the application.
My operating system of choice is Raspberry Pi OS Lite because it is native to the Raspberry Pi and based on Debian, which offers a great deal of support from communities online.
I prefer to download using a torrent because it is often faster. The file is downloaded piece by piece from various servers rather than from a single source.
Flashing the Operating System
-
Open Etcher and click
Flash from fileto choose the downloaded.imgfile. -
Click
Select Targetand choose the external media device that you want to flash the operating system onto. -
Click
Flash!.
Enabling SSH via Terminal.app
-
Since Etcher automatically ejects the external media once it finishes flashing the operating system, plug the external media device back into your Mac.
-
Open a new Terminal window and move into the boot volume.
cd /Volumes/boot
- Create a blank
sshfile to enable SSH on the Raspberry Pi.
touch ssh
- Return to your home directory.
cd
- Eject the external media device and remove it from your computer.
Powering Up
-
Insert the microSD card into the Raspberry Pi.
-
Connect one end of an Ethernet cable to the Raspberry Pi and the other end to your router.
-
Plug the power cable into the Raspberry Pi.
Connecting via SSH
- Open a new Terminal window and ping the Raspberry Pi.
ping raspberrypi.local
- You should see output similar to this:
PING raspberrypi.local (192.x.x.x)
The numbers inside the parentheses that start with 192 or 10 will be the IP address of the Raspberry Pi.
To stop the continuous ping, press Control + C.
- Start the SSH session.
ssh pi@<ip-address>
- If you see a warning that the authenticity of the host cannot be established, type
yes.
This happens because the SSH client has never encountered the server’s key fingerprint before.
- Enter the default password.
raspberry
No text will appear as you type the password. This is a normal security measure.
Changing the Default Password
I highly recommend changing the default password to increase the security of your Raspberry Pi.
- Start the password change process.
passwd
-
Enter the default password.
-
Enter your new password.
Updating
It’s a good idea to update your packages periodically.
- Update all currently installed packages and upgrade them.
sudo apt-get update && sudo apt-get upgrade -y
- Reboot the Raspberry Pi to make sure the changes go into effect.
sudo reboot
The current SSH session will terminate automatically when the Raspberry Pi reboots.