Philipp Conen

Engineering meets hobby.

Headless setup of Raspberry Pi OS with wifi & SSH

Introduction

One may be asking if another tutorial about how to set up a Raspberry Pi is really necessary. The general answer would be no.

But as I have some Raspberry Pi projects finished or in focus, I’d like to have the information about a clean Raspberry Pi setup all in one place, so I can refer to this post while working on other projects.

1. Download Raspberry Pi OS

The Raspberry Pi has an own OS, called Raspberry Pi OS. It pretty equals Ubuntu. Due to this fact most commands and tutorials which exist for Ubuntu, also fit for the Raspberry Pi OS.

Now it is necessary to know, which OS is the best choice for you. This depends on the situation of the usage. So if no graphical user interface (GUI) is needed, I would recommend Raspberry Pi OS Lite, because it is light, fast, and efficient. The other options are available in the following table.

Raspberry Pi OS Suitability
With desktop & recommended software End usage without much configuration effort
With desktop Lightweight system with GUI
Light Ultralight system when no GUI is needed

If you know which Raspberry Pi OS fits your demands you can download it here.

2. Flashing the SD card

For the flashing process, I recommend Balena Etcher. After installing Balena Etcher one can start the flashing process.

Select the location of the ISO image on your operating system. Chose the installation device (e.g. SD card or USB stick) to where you want to burn the image to. Start the burning process.

3. Headless configuration

Now the headless configuration needs to be done. Reinsert the flashed SD card and navigate to the boot directory. Depending on the Linux distribution this could be hard to find. For my Arch Linux system, I found it via
cd /run/media/philipp/boot/
Make sure the device is mounted.

First, add a document called ssh by
touch ssh
without a file extension and content.

Also, add another document called wpa_supplicant.conf using
nano wpa_supplicant.conf
and fill it with the following content

country=DE
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
       ssid="SSID_Name"
       psk="SSID_Password"
       key_mgmt=WPA-PSK
}

Remember to change the ssid (name of the router) and the psk (password of the router).

4. Connect to the Raspberry Pi

If everything worked out, one should be able to connect to the Pi via ssh
ssh pi@ip_address

To explain what happens here, pi is the username of the Raspberry Pi you want to log into, and ip_address needs to be replaced with the original IP-address the Pi gets from the network (e.g. 192.168.5.157). To find out the IP-address log in to the router and take some research on the connected devices. After entering the command, a password is required. The default password for the Raspberry Pi should be raspberry.

Regarding this, the first action which should be done is to change the password
sudo passwd pi

Also, I would recommend updating the system via
sudo apt-get update
and
sudo apt-get upgrade

Conclusion

By going through the aspects of downloading a suitable Raspberry Pi OS, burning the image on a bootable device, setting up SSH and Wifi headless, we now have a working Raspberry Pi which can be used normally or via remote.


Sources

Links Latest Access
Balena Etcher 17.05.2021
Change Password 17.05.2021
Raspberry Pi OS 17.05.2021
Last updated on 1 May 2021
Published on 1 May 2021
 Edit on GitHub