In this article, we will show how to configure and access a Raspberry Pi (let’s call it Pi) for the first time without any monitor, keyboard or Ethernet cable connected to it. At the time of this article, this tutorial is applicable to the Pi 4 B.
Prepare the SD card
First of all, we assume that we have a computer running on Linux, and a SD card containing a fresh install of Raspbian. We also need a wifi network on which the computer and the Pi can connect. If you don’t have any, you can use your mobile phone in hotspot mode.
Raspbian is a Linux distribution based on Debian and optimized for the Pi. This tutorial explains how to write a Raspbian image on a SD card. Keep the SD card inserted in your computer.
SSH is a program for logging into and executing commands on a remote machine. On Raspbian, SSH is installed but disabled by default. SSH can be enabled by placing an empty file named
ssh, without any extension, onto the
boot partition of the SD card. At the next boot, the Pi will look at the
ssh file, enable SSH and delete the file.
Setup the wifi
wpa_supplicant.conf is used to configure wireless network devices. In this file, we will request the Pi to connect automatically to a given wireless network.
First of all, identify the name of the wifi network your computer is connected to and its passphrase. For a better security, we encrypt the password using
And type the passphrase of the wifi network. This will generate an output such as:
You can safely remove the line starting with
#. On the
boot partition, create the file
wpa_supplicant.conf in the root directory, and write:
<country_code>is the code of your country.
<ssid>is the name of the wifi network.
<psk>is the encrypted passphrase.
Detect the Pi
Insert the SD card in the Pi and turn it on. It should attempt to connect to your wifi network in a short time. To check if the Pi is properly connected, run the command:
If the Pi is detected, you should see:
Connect to the Pi
Now that you know that
raspberrypi.local is the network address of the Pi, you can start your first SSH session by running:
The initial password is
raspberry. After your first login, change the password by running:
SSH - Raspberry Pi documentation ↩︎
Setting Wifi up via the command line - Raspberry Pi documentation ↩︎