Knowledge for the World

How to set up your Raspberry Pi without a keyboard, monitor, or mouse

If you don't have an extra keyboard and monitor laying around, or if you generally prefer working on the command line, then you'll benefit from a headless Raspberry Pi setup. In this case, headless simply means that we'll set up and use the Raspberry Pi without any monitor or other GUI. This guide will walk you through the process of setting up a headless Raspberry Pi.

I recommend using a Raspberry Pi Zero W or Raspberry Pi 3 since they have onboard WiFi. If you're using a different version of the Pi, you'll need to a add a Raspberry Pi WiFi USB adapter.

In addition to the Pi, you'll need a power supply, SD card, and another computer.

1

We've written a detailed guide on how to install Raspbian on your Raspberry Pi. Follow this guide to get the latest version of Raspbian on your SD card.

After installing Raspbian on the card, leave the SD card in your computer. We'll do much of the remaining setup from here.

2

To enable SSH, first navigate to the boot directory:

cd /Volumes/boot

Now create an empty file called "ssh":

touch ssh

This will enable SSH when the Pi is booted. If you need more details on this process, view the full guide to enable SSH on Raspbian without a screen.

3

In order to SSH into your Pi, you'll need to be connected to your local network. You can, of course, use Ethernet, but if you're using the Raspberry Pi 3, you've got WiFi built-in. So let's add our WiFi configuration to the Pi so it's available when we boot.

Navigate to the boot directory:

cd /Volumes/boot

And create a file called wpa_supplicant.conf. Add the following to this file:

For Raspbian Jessie:

network={
    ssid="YOUR_NETWORK_NAME"
    psk="YOUR_PASSWORD"
    key_mgmt=WPA-PSK
}

For Raspbian Stretch:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
network={
    ssid="YOUR_NETWORK_NAME"
    psk="YOUR_PASSWORD"
    key_mgmt=WPA-PSK
}

You'll need to add your wireless network name and password.

Again, if you need more details on this process view the full guide on how to set up WiFi on your Raspberry Pi without Ethernet.

4

At this point, you can access the Raspberry Pi via SSH. Remove the SD card from your computer, then put it in the Pi and boot.

5

Now we'll need to find the IP address of the Pi. If you've only got one Pi on your local network, this is easy. Simply use ping.

ping raspberrypi

If you've got multiple pi's, you may need to scan the network with nmap and locate your Pi.

nmap -sn 192.168.1.0/24

You'll need to make sure you're using the correct subnet. Then find the address of your Pi in the output. For more information see the full guide on finding the IP address of your Raspberry Pi.

6

With the IP address located, you can SSH into the Pi using:

ssh pi@192.168.1.183

Of course, you'll need to substitute your IP address.

7

This is not a necessary step, but for many it's preferable to mount the Pi's filesystem locally rather than work directly on the Pi. We'll use sshfs to create the mount, so first install sshfs.

Now create the directory where you'll place the mount. I'm going to use /Volumes/pi.

sudo mkdir /Volumes/pi

Now create the mount.

sudo sshfs -o allow_other pi@192.168.1.183:/ /Volumes/pi