Raspberry Pi setup under Raspbian without any monitor or cable
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.
Enable SSH
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[1]. At the next boot, the Pi will look at the ssh
file, enable SSH and delete the file.
Setup the wifi
The file 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[2].
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 wpa_passphrase
:
And type the passphrase of the wifi network. This will generate an output such as:
network={
ssid="<ssid>"
#psk="<passphrase>"
psk=103f69f05b3fdd791067919813682829d5999a1be2a1e3a2c1b608c1def6d1d9
}
You can safely remove the line starting with #
. On the boot
partition, create the file wpa_supplicant.conf
in the root directory, and write:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=<country_code>
network={
ssid="<ssid>"
psk=<psk>
}
Where:
<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:
Enjoy!