Set up a Raspberry Pi as a Headless Server [Using Linux]

Installation Guide

June 14, 2019

A common use for the Raspberry Pi is as a low-powered headless server on which you can install a web server such as Nginx, a Plex media tracker such as Tautulli, a network-throughput measuring tool such as tshark, or network-device management tools such as UNMS or Unifi Controller. This guide will show you how to use your Linux machine to set up your Pi so that you can use it for one these purposes. If you need the Mac guide instead, look here.

If you haven't got the Pi yet, we would recommend picking up the CanaKit Raspberry Pi 3 B+ kit, with a SanDisk 32GB MicroSD card (adapter included).

Step 1

Download “Raspian Stretch Lite” from the Raspberry Pi website. Do not download either of the desktop versions on offer. You do not need them for a headless installation.

Step 2

Install Balena Etcher on your Linux machine. You can get the latest version here.

Step 3

Insert the MicroSD card that came with your Raspberry Pi into your Linux machine. For most Macs, you will need an adapter.

Step 4

Open Balena Etcher on your Linux machine. Click “Select Image.” Navigate to the “Raspian Stretch Lite” file that you downloaded in step one. Then click “Flash.” You may be asked to enter your computer’s password.

Step 5

After Balena Etcher has finished flashing the image, it will automatically dismount the MicroSD card. Once you are satisfied that it has finished, re-insert the MicroSD card and wait for your Linux machine to recognize it as an external drive with the name boot.

Step 6

Navigate to the MicroSD card’s root directory and add a blank file named ssh. Do not add an extension (.e.g .txt). This will allow you to connect to the Raspberry Pi using SSH.

WARNING If you skip this step, you will not be able to proceed.

Step 7

Physically remove the MicroSD card from your Linux machine. Insert the MicroSD card into the Raspberry Pi. Connect the Raspberry Pi to your network with an ethernet cable. Plug the Raspberry Pi in.

Step 8

On most networks, the Raspberry Pi will automatically be given an IP address by the DHCP server Before proceeding, you will need to find what this IP address is. If you have a Fingbox, or other network monitoring tool, it will tell what you what this is automatically. Alternatively, you can log in to your router and look at the DHCP tables.

Step 9

Next, we will SSH in to the Pi from the Linux machine. The default username is pi. The default password is raspberry. Assuming that its IP address is 10.0.1.179, you would type:


      ssh pi@10.0.1.179

If prompted, type yes when asked to “accept authenticity.”

Then enter the default password, which is raspberry.

Step 10

Once you are logged in, you should update the software on the Pi. To do this, type:


      sudo apt-get update && sudo apt-get upgrade

Settle in. This can take ten minutes or so.

Step 11

Once the software has updated, we will change some system-wide settings. To enter the configuration area, type:


      sudo raspi-config

First, you should change the default user password to a password of your choice. When you’ve done this, write it down. If you lose it, you’ll need to start over.

Next, you should change the Pi’s hostname (Network OptionsHostname). This can be anything, but if you intend to give the device a fully qualified domain name, you’ll want to keep it consistent with the rest of your network: e.g. server.your.house.

Next, you can change the localization options. This step is not mandatory.

Next, you should expand the file system so that the Pi can use the entire MicroSD card. (Advanced OptionsExpand Filesystem).

When you are done, exit the configuration tool by selecting “Finish” and agreeing to reboot.

Step 12

Given that our purpose here is to set up the Pi as a server, we highly recommend assigning it a static IP address. To avoid multiple devices trying to take the same IP address, this is best done from the DHCP side—that is, on your router or standalone DHCP server.

Your Pi is now ready to be used as a headless server. To make accessing it via SSH easier, we would recommend first setting up passwordless access via keys, and then setting up SSH shortcuts on your client machine.

Versions

Raspbian Stretch Lite: 4.14
balenaEtcher: 1.5.45
Notice an error?

Have we got something wrong? Please let us know and we’ll fix it right away.

Tags

Join the Discussion

Your email address will not be published. Required fields are marked *