github linkedin scholar
Raspberry Pi Simple Headless Setup
Jan 28, 2018
4 minutes read

Setting up a headless Pi is useful because it doesn’t require you to set up a whole workstation (monitor, keyboard, mouse, etc) for simple applications. All you need is an Ethernet cable. This guide allows you to set up a ssh-able Pi without much trouble.

This will work for both wired and wireless LANs.

1. Install the Raspbian image on a SD card.

2. Enable ssh on the Pi.

On a desktop or laptop computer, mount the SD card’s boot partition (note, this is the boot partition, not the /boot directory on the SD card’s root partition), and create a file called ssh there. This will auto-start the ssh daemon when the Pi boots.

3. Boot the Pi.

On your laptop, go into network settings, and change your wired Ethernet connection settings to Link-Local. It is usually the setting with the value “DHCP”. Check your laptop’s wired interface’s IP address, it should begin with 169.254.

Plug in one end of the ethernet cable into your Pi, and the other into your laptop, and then power on the Pi.

5. Find the Pi’s IP Address.

After a minute or two, the Pi should be fully booted and should have configured itself automatically with a randomly assigned link-local address. To discover that address, we can run the following command from the laptop (I’m assuming you are running some Linux and eth0 is your interface name, but Mac and Windows should have similarly convenient commands to find link-local IPs):

sudo arp-scan -l --interface=eth0

You should get an entry with another IP address that looks like 169.254.x.x, belonging to Raspberry Pi Foundation. This is your Pi’s IP address! You can SSH into the Pi address you’ve found with ssh pi@169.254.x.x, and the default password raspberry.

Alternatively, you can try finding the IP using IPv6 broadcast:

ping6 -I eno1 ff02::1

6. Install Avahi.

Now we can talk to the Pi just fine, and could stop here, but this link-local IP address is subject to change on reboot, as well as hard to remember and work with. So in this step we’ll set up Avahi (Linux zeroconf implementation) to allow us to connect to the Pi by simply calling:

ssh pi@raspberrypi.local

Ssh to the Pi, and once inside run the following:

  • Run sudo raspi-config, and expand the SD card partition, change your password, hostname, set timezone, connect to wifi, etc.
  • Install the avahi daemon via sudo apt install avahi.
  • (Optional) Run sudo apt-get install unattended-upgrades to ensure the Pi updates itself automatically.
  • (Optional) You can also install tmux to make working with ssh more pleasant.

Reboot your Pi, and from your laptop run this to see if the Pi is visible (its address should be [your Pi's hostname].local):

avahi-browse -at

Done! You can now use this address to ssh to your Pi from any device in its local network, wired or wireless.

Bonus: Set up your Pi as a WiFi Access Point.

This happens to be the reason I had to set up a Pi this time. I needed wifi, but all I had was a single ethernet drop in a wall, so I decided to make an AP using a Pi.

If you are in a similar situation, install the following:

sudo apt install network-manager

And run the following commands to create a hotspot. Be mindful of replacing wlan0 with your actual interface name, RpiHotspot with your actual hotspot name, and set the password to what you like.

nmcli con add type wifi ifname wlan0 con-name RpiHotspot autoconnect yes ssid RpiHotspot
nmcli con modify RpiHotspot 802-11-wireless.mode ap bg ipv4.method shared
nmcli con modify RpiHotspot wifi-sec.key-mgmt wpa-psk
nmcli con modify RpiHotspot wifi-sec.psk "set your own password here"
nmcli con up RpiHotspot

Then, power off the Pi, plug one end of an Ethernet cable into the Pi, and the other into the wall (I’m assuming your “wall” is configured with DHCP in a reasonable way), and then power on the Pi again and wait for your new AP to appear!

If you need to ssh to the Pi, you can connect to the Pi’s AP and just ssh to the gateway.


  • To check what’s going on with NetworkManager, use the nmcli tool.
  • Remember to sudo rm /etc/wpa_supplicant/wpa_supplicant.conf to ensure network-manager gets used.

Back to posts

comments powered by Disqus