Setup a headless Raspberry Pi for DIY experiments

Headless Raspberry Pi (RPi) computers are quite useful and handy for DIY types and makers.

By headless, we are talking about no monitor or keyboard attached. And no desktop GUI or Graphical User Interface.

This RPi is purely for power and performance. Access is only via a SSH connection, or command line interface. If that is alien or scary, or you don't know what a shell, command line or terminal access is, you may want to start somewhere like here.

Note - The method to create a headless RPi has changed over time. If you search the internet you will find different methods. For example:

Burning the Operating System (OS) image file onto the microSD card used to be complicated, error prone and ugly. It was also different depending on what PC OS you were using to burn the image - Windows or Apple Mac for example. Horrible. Then a company called resin.io changed all that nonsense when they released their cross platform burning software called Etcher in late 2016. OS image burning is now simple thanks to resin.io.

Unfortunately, around the same time, something that used to be automatically enabled, simple and working in every newly burned image of the RPi Rasbian OS, the SSH server, was disabled by default. The Raspberry Pi foundation had a little panic attack fearing 1000s of RPi's might be taken over by nefarious actors, so they made it complicated again to build a simple headless RPi.

I'll endeavor to update this post as and if methods change again.

You will need:

  • A RPi computer (any version with an Ethernet network interface)
  • A suitable power supply
  • An Ethernet cable to connect the RPi to an internet router
  • A microSD memory card (min. 4GB) for the RPi Raspbian Jessie Lite Linux OS
  • A microSD to USB card reader/writer or slot in your PC, to burn the OS image
  • A copy of Etcher to burn the OS image file onto the microSD card
  • [option] A case for the RPi

Step 1 - Download the latest RPi OS

Via direct download or even better, torrent, you should download a ZIP file of the latest Raspbian Jessie Lite image file from here:

https://www.raspberrypi.org/downloads/raspbian/

Step 2 - Burn the Raspbian OS image onto the microSD card

Insert the microSD card into the microSD/USB card reader/writer or slot in your computer. Run the Etcher burning program.

Etcher unzips the image file automatically so no need to unzip the *.img file first. Follow the Etcher instructions and burn the image file from the ZIP file to the microSD card. Once the *.img file is successfully written and verified, Etcher will unmount the microSD card. You need to re-mount it as you are not finished yet. Removing and re-inserting the microSD card will remount it.

Step 3 - Add a file named "ssh" to boot partition on imaged microSD card

Step 3a: Windows computers

First, you need to find out what drive letter has been assigned to the boot partition of the imaged microSD card. In the below image of my Windows 7 PC, you can see that the "E:" drive is the one on my PC. If yours is different, substitute as appropriate.

Open a command prompt window and type

e: <enter>

to switch to drive E: then type

copy /b NUL ssh <enter>

to create an empty file called "ssh" on the boot partition.

Safely eject the microSD card. Continue at Step 4.

Step 3b: Apple Mac computers

Open a command prompt in terminal and type

mount | grep "boot" <enter>

This will give you output something like

/dev/disk2s1 on /Volumes/boot (msdos, local, nodev, nosuid, noowners)

Here, the "/Volumes/boot" part is the text you want. Add an "/ssh" suffix to that to construct this text >> "/Volumes/boot/ssh" for use with the "touch" command. Obviously adjust the text as per your computer's output.

touch /Volumes/boot/ssh <enter>

to create an empty file called "ssh" on the boot partition.

Safely eject the microSD card.

Step 4 - Assemble RPi, plug into Internet router, power on

If you are using a case with your RPi, please assemble it, with the RPi now. Plug the micro USB power cable into the RPi from the power supply. Insert the power plug of the power supply into a free power socket. Plug one end of the Ethernet cable into the RPi and the other end of the cable into a free Ethernet port on your Internet router or switch.

Step 5 - Find the IP address of the RPi on your local network and SSH connect into the RPi

Turn on the power. The next part involves finding the IP address of the RPi so you can SSH into the RPi on your local network.

You can find the local IP address of the RPi by examining the DHCP "leases" or "clients" via the Web application running on your Internet router.

Step 6 - SSH into the RPi

In your favourite terminal emulator, where 1.2.3.4 is the IP address of your RPi discovered in Step 5 above, type

ssh [email protected] <enter>

password: raspberry <enter>

Next

Related Articles

Network Engineering
Network EngineeringBig TechRPiExpert

Telstra smashes Google in DNS speed test