Categories
Raspberry Pi

Raspberry Pi Headless Setup

A headless setup is one which isn’t going to be connected to a monitor, keyboard or mouse. In general it is appropriate if you are planning on using the device as a server rather than a general desktop computer.

So how can you configure your Raspberry Pi if it hasn’t got a screen, keyboard or mouse?

The answer is that you to access it via ssh (Secure Shell).

Firstly download an operating system image from https://www.raspberrypi.org/downloads/raspbian/ you will want the “lite” version for a headless setup. Next install the image onto a microSD card using a tool such as balenaEtcher.

Your microSD card will now have two partitions, a boot partition in FAT format and the main Linux partition in ext4. Insert the microSD card into your computer (using an adapter if necessary) and a drive named “boot” should appear.

Open the “boot” drive and create an empty file simply called “ssh” in the top level of the drive – this will enable the ssh server when you first boot your Raspberry Pi.

If you are connecting your Raspberry Pi to the network using a standard ethernet cable then connect it now and skip the WIFI configuration.

WIFI Configuration

If you are connecting your Raspberry Pi to your WIFI network then you will been to add another file called “wpa_supplicant.conf” to the top level of the boot drive. The file should contain the following information but obviously update the country code, WIFI SID and WIFI password as appropriate.

country=GB
 ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
 update_config=1
 network={
     ssid="REPLACE-WITH-WIFI-SID"
     psk="REPLACE-WITH-WIFI-PASSWORD"
 }

First Boot

The microSD card can now be inserted into the Raspberry Pi and the system can be booted. After a few minutes it should be possible to login to the Raspberry Pi using a ssh client. The IP address that has been assigned to the Raspberry PI can by checking the config of the internet router that it is connected to. If there is only a single Raspberry Pi on the network then it might be possible to login simply by entering:-

ssh pi@raspberrypi

You will be prompted to enter a password. The initial password for the ‘pi’ user is ‘raspberry’ which should be changed immediately upon login using the passwd command.