Pure headless Raspberry Pi setup from scratch

This guide assumes there is no Internet, no Wifi, no router, no display, no keyboard. It assumes you have a Raspberry Pi with built-in Ethernet port.

  1. Download .zip of latest Raspbian .img file
  2. a Raspberry Pi and another Linux computer (could be a second Pi already running).
  3. a plain (or crossover) Ethernet cable–no router/switch required

1. Prepare laptop

We are going to use link-local networking, where the IP address will be in the 169.254.*.* range, no DHCP server needed. Here we assume NetworkManager on your laptop.

  1. create a new Ethernet connection, name it “link local” for convenience.
  2. under this new connection’s IPv4 settings, choose “link-local only”.

Note you may need to manually select this network profile when you plug the Pi into your laptop.

2. prepare SD card

Find SD card mount point: before and after inserting it into the laptop:


Example assumes the SD card is at /dev/mmcblk0. Be sure you have the right device! Burn the .img to the SD card (permanently erasing previous files on the SD card):

unzip -p *raspbian*lite* | sudo dd of=/dev/mmcblk0 bs=4M status=progress conv=fsync

This takes a few minutes and there’s no progress indicator. You can use iotop to watch how fast it’s writing.

When writing appears done, type


to be sure it’s done writing.

In the SD card boot partition enable SSH on the headless Pi for first boot by

touch ssh

which creates a blank file named ssh. N.B.: this is NOT the boot directory in the 4 GB main partition of the SD card, this is a separate < 100 MB partition named boot. It has other important files like config.txt in it.

(Optional) Headless WiFi is enabled by editing from your laptop on the SD card the file /etc/wpa_supplicant/wpa_supplicant.conf and adding lines like

   ssid="my cool wifi router"
   psk="my wifi password"

Optionally, prioritize Wifi networks by the priority field, which can be a positive or negative integer.

  • default priority is 0.
  • equal priority Wifi then compared based on signal strength, security, etc.

“eject” or unmount the SD card before removal, to avoid corrupting the SD card file system.

3. first boot headless Pi

Insert the SD card into the Pi and boot. After about one minute, on your laptop plugged directly to the Pi via Ethernet:

ssh pi@raspberrypi.local

default password is raspberry

Logged into the Pi, change the default password to something else with


set unique hostname: raspi-config. If chose mypi then after Pi reboot:

ssh pi@mypi.local

Set locale to be UTF-8. Assuming you wish to have the United States locale, uncheck the default GB and check en_US.UTF-8 UTF-8. When prompted for default locale, also selected en_US.UTF-8 UTF-8.

  • if you don’t pick a UTF8 locale, Python may give UnicodeDecodeError with UTF8, even when .py script already has # -*- coding: utf-8 -*-.

Again assuming you’re using a United States keyboard, set keyboard layout in raspi-config to Generic 104 keyboard, United States layout to avoid not being able to type symbols properly.

Reboot, particularly to make the locale settings take effect.

Just a simple network switch connecting Raspberry Pis, PCs and other devices makes an internet-free, pure link-local “off the grid” network. Of course, you can also put the Pis on a wired or wireless network connected to the Internet if desired. The .local address functionality will NOT work over the Internet, but only on the LAN segment your device is on.

SSH server

Without further configuration, SSH servers listen on all interfaces. Normally this is fine.

If you want only specific interface(s) to have the SSH server listen, you will need to research ListenAddress of /etc/ssh/sshd_config and/or IPTables.