When you don’t have or feel like hooking up a monitor and keyboard
We will be installing a headless version of the Raspberry Pi OS, which can
be downloaded from the Raspberry Pi Foundation here: https://www.raspberrypi.org/software/operating-systems/
As of April 2021, the three downloads available are:
- Raspberry Pi OS with desktop and recommended software
- Raspberry Pi OS with desktop
- Raspberry Pi OS Lite
We will be downloading Raspberry Pi OS Lite, which is a headless version of the OS. That is, there is no graphical user interface available. We will instead enable the SSH server as part of the installation process and login via an SSH client.
After downloading the OS Lite ZIP file, we need to extract it to an IMG file and then flash it to a microSD card (8GB minimum). Once the card is flashed, eject it and reinsert the SD card into your computer. You should now see a volume called `boot`. On MacOS, this will be located at `/Volumes/boot`.
Open a terminal and navigate to the boot volume:
If you list the files `ls`, you should see a collection similar to the following:
λ /Volumes/boot/ ls
COPYING.linux bootcode.bin kernel7.img
LICENCE.broadcom cmdline.txt kernel7l.img
bcm2708-rpi-b-plus.dtb config.txt kernel8.img
bcm2708-rpi-b.dtb fixup.dat overlays
bcm2708-rpi-cm.dtb fixup4.dat start.elf
bcm2708-rpi-zero-w.dtb fixup4cd.dat start4.elf
bcm2708-rpi-zero.dtb fixup4db.dat start4cd.elf
bcm2709-rpi-2-b.dtb fixup4x.dat start4db.elf
bcm2710-rpi-2-b.dtb fixup_cd.dat start4x.elf
bcm2710-rpi-3-b-plus.dtb fixup_db.dat start_cd.elf
bcm2710-rpi-3-b.dtb fixup_x.dat start_db.elf
bcm2710-rpi-cm3.dtb issue.txt start_x.elf
To enable the SSH server, simply add a file named `ssh` to this directory:
If you’re going to connect the Raspberry Pi to your network directly via an ethernet cable go ahead and skip the next step, otherwise follow along. Now we’re going to provide WiFi credentials with a text file called `wpa_supplicant.conf`. Open up your preferred text editor and create `wpa_supplicant.conf` inside of the `/Volumes/boot` directory with the following content:
This configuration file is setup for a primary (`priority=2`) and a secondary (`priority=1`) WiFi network. That is, if both of the networks above are available, the one with the highest priority value will be the one the Raspberry Pi attempts to connect with. If you don’t have more than one network, the second block can be ignored. Substitute the credentials you have for `ssid`, `psk`, and `id_str`, for the Wifi SSID, password, and a unique ID of your choosing, respectively. Once this file is saved, eject your microSD card and insert it into the Raspberry Pi. Provide power to the device and check your WiFi router to see if it’s connected.
My WiFi router serves up a web interface on `192.168.0.1`. Check your router for this info as well as a username and password. After checking the connected devices on my WiFi network, I see there’s a device with a hostname of `raspberrypi` and IP address `192.168.0.71`. Note that your IP addresses will most likely be different.
Let’s login to the Raspberry Pi with our SSH client. Open a terminal and type the following (note use your Raspberry Pi’s IP address in lieu of 192.168.0.71):
You will likely get a warning such as `The authenticity of host ‘192.168.0.71 (192.168.0.71)’ can’t be established […] Are you sure you want to continue connecting (yes/no/[fingerprint])?`. Go ahead and enter`yes` and you’ll be prompted for a password. The default password is `raspberry`. After a successful login, you’ll be greeting with a terminal similar to the following:
Linux raspberrypi 4.19.118-v7+ #1311 SMP Mon Apr 27 14:21:24 BST 2020 armv7lThe 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.SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.pi@raspberrypi:~ $
Go ahead and run the following commands to make sure your OS is completely up to date:
sudo apt-get update
sudo apt-get upgrade
Congrats! You’ve successfully installed a headless version of Raspberry Pi OS and connected via SSH.