Instructions for headless setup of a Raspberry Pi
While Raspberry Pi’s can be used with a monitor and keyboard, they don’t have to be. You can configure and access a RPi via another computer. This install is called “headless” because there’s no monitor to provide a GUI on the RPi.
This guide will reference MacOS computers and terminology, but the instructions are virtually identical for Windows PCs.
Hardware:
- A computer
- RPi with power supply
- microSD card (8GB minimum - more info here: SD cards - Raspberry Pi Documentation)
- microSD card reader
- ethernet cable (optional - obtain one if you won’t be using your RPi on your Wifi network)
Downloads:
- Etcher - balenaEtcher - Home
- IP Scanner - Angry IP Scanner
- Raspbian Buster with Desktop - Raspbian Download
Other
- Access to your router’s admin section (optional - can use Angry IP Scanner)
- Download all the download items above. Install Etcher and Angry IP Scanner.
- Plug in the microSD card into your computer and ensure your computer detects the microSD card.
- There’s a permissions issue with Etcher on macOS Catalina (10.15). You’ll need to open up your Terminal app and run Etcher as superuser. Cut and paste this command and enter your computer password when prompted:
sudo /Applications/balenaEtcher.app/Contents/MacOS/balenaEtcher
- With Etcher open, click on /Select image/ and select the .zip file of the Raspbian image you downloaded.
- Click on /Select target/ and select the microSD card from the list. Double check you have selected the correct drive in this step.
- Click on /Flash/. It will take several minutes for this process to complete. Meanwhile you can prepare for the following steps.
- If you want your RPi to access your Wifi network automatically when booting up, you will need to tell it how. /You can skip to step 19 if you will connect your RPi to your network via an ethernet cable./ Download the
wpa_supplicant.conf
file and open it with TextEdit by right-clicking on the file, selecting /Open With/ > /Other…/ and then finding TextEdit in the window that opens. - Edit the
country=
entry with your country’s 2 digit code. You can find the codes in this Wikipedia entry: Country Codes ISO 3166-1 - Wikipedia - Edit the
ssd=
entry and input your Wifi network name inside the quotes. - Edit the
psk=
entry and input your Wifi password inside the quotes. - Save your update
wpa_supplicant.conf
file - Etcher will need to have completed it’s loading of the Raspbian OS to the microSD card at this point. Once it’s done, eject the miroSD card and then plug it back in. It should show up as a drive named “boot”
- Place
wpa_supplicant.conf
in “boot”. Make sure it’s in the root location of your microSD card and not in any folders. - Next, open up the Terminal app.
- In Terminal, type the following and hit enter:
cd /Volumes/boot
- To check if you’re in the right directory, type the following and hit enter:
ls -la
If you see several files and amongst themwpa_supplicant.conf
then you’re in the right location. - Type the following and hit enter
touch ssh
This will create an empty file called “ssh” in “boot”. When your RPi starts up this will tell it to start an ssh server. - Us the
ls -la
command to make sure the ssh file is in “boot” - Eject the microSD card
- In order to connect to the RPi, it’s IP address on your network needs to be known. Open Angry IP Scanner.
- To the right of the /Start/ button there is a two column icon with multiple lines, click on it. A window called “Fetchers” will open.
- Click on “MAC Vendor” in the right column and click on the left arrow to add it to the “Selected fetchers column on the left. Do the same for “MAC Address”.
- Close the “Fetchers” window.
- Insert the microSD card into the RPi.
- If you are not using Wifi with your RPi, connect it to your router with an ethernet cable and power it on. If you are using Wifi with your RPi, power it on and wait a minute for it to boot up.
- Press /Play/ in Angry IP Scanner. Once it’s done scanning you’ll see an entry for the RPi along with its IP address. Take note of this IP address. As an example will say it is 192.168.1.X (your IP address will be different, it could be 10.0.0.X).
- Open Terminal and type the following and hit enter:
ssh pi@192.168.1.X
- Enter the password
raspberry
and hit enter. - You’ll see a message regarding security and RSA keys. Type “yes” and hit enter to proceed. You’ve now accessed your RPi via ssh!
- It’s important to change the default password. While accessing your RPi via ssh, type the following and hit enter
passwd
It will ask you for a new password. Don’t forget it!
Routers cycle through IP addresses and unless you instruct your router to use the same IP address with a device, the IP address might change at some point. Instructions on how to do this very from router to router. Do a search for "how to set static IP address [your router model goes here]" and you should find instructions on how to set a static IP address for the RPi.
You can now connect to your RPi and use it via command line from another computer without needing a keyboard or monitor connected to your RPi.
Inspiration and content for this guide comes form this Youtube video by Brian Lough: A Truly Headless Setup for your Pi