Connecting a Raspberry Pi to a local network

A guide to get your Raspberry Pi connected to a local network, via ethernet or Wi-Fi.

Configuring network access

If your Pi is connected to the network via an ethernet cable, you can skip this section. Unless manually changed, our device will be available on the network under the default hostname raspberrypi.local.

Insert the SD card into your computer and create a file called wpa_supplicant.conf at the root of the boot volume of the SD card (e.g. /Volumes/boot on macOS). Paste the following:

country=COUNTRY
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
    ssid="<Your wifi network name>"
    psk="<Your wifi network password>"
    scan_ssid=1
    key_mgmt=WPA-PSK
}

Do not forget to update the ssid and psk keys.

COUNTRY should be set the two letter ISO/IEC alpha2 code for the country in which you are using your Pi, e.g.

  • GB (United Kingdom)

  • FR (France)

  • DE (Germany)

  • US (United States)

key_mgmt should be set according to your psk. If your network is protected by a WEP key, leave this field empty.

If you’re looking for more details about this step, please refer to the Official Raspberry Documentation.

Enabling SSH

In order to access your Pi via SSH, you need to enable SSH. To do so, add an empty file, called ssh, at the root of the boot volume on your SD card (same location as wpa_supplicant.conf from the previous step).

Accessing the Pi

Eject the SD card from your computer, and insert it into the Pi. It will take roughly 20 seconds to boot. You can then access your Pi from your computer via SSH using the following command from a console prompt:

ssh pi@raspberrypi.local

The default password is raspberry.

If you are unable to connect, make sure your computer is connected to the same network as your Pi, as specified earlier in wpa_supplicant.conf.

Changing the hostname

If you wish to name your device something else than raspberrypi, in particular if you have several Pi devices on your local network, you may change the hostname by running raspi-config from your Pi:

(pi) sudo raspi-config

Go to the “Hostname” menu, type in the desired name, for instance raspi-basement, and reboot. Next time you want to access your Pi via SSH, use the new hostname instead of raspberrypi, appended with .local:

ssh pi@raspi-basement.local

Last updated