Insallation de Raspbian sans clavier et sans écran

How to do a Raspberry Pi headless setup

Mis à jour le 26 July 2017 - 0 Commentaires -

In many cases, the solution we want to install on our Raspberry Pi does not require physical access to the Pi, such as an web server, or a Minecraft server. It may happen that we do not have any screen, keyboard, or mouse to control the Raspberry. So you’re going to be thrilled to know that to create a Raspbian system, we do not need any screen or keyboard, and your computer can do the job.

Indeed there is a solution to configure Raspbian on the Raspberry Pi headless, so it can start and connect in Wi-Fi to your Internet network. This method mean you will not use any screen or keyboard to install and configure Raspbian.

Elements required to set up your Pi

In order to make a Raspbian installation on the Raspberry Pi, you will need all the essential elements, a Raspberry Pi 3b , its power supply , and a MicroSD card (8GB is sufficient).

You will also need to download the latest version of Raspbian, which can be downloaded here . We recommend the Lite version because we do not need the GUI. No need to take a coffee break, Raspbian Lite is relatively lightweight and downloads pretty fast. Once the image is downloaded and decompressed, you will have to install it on the SD card, for that we made a detailed article ( here for Windows and there for Linux / Mac ).

Configure the MicroSD card

Now that Raspbian is installed on the SD card, we will be able to configure and modify some files so that the Raspberry Pi can run headless. To do this, we will start by activating SSH on the Raspberry Pi. Remember, the rest of the tutorial is on your PC and not on the Raspberry Pi.

Enable SSH connection

Indeed since the attack that targeted the connected objects in November 2016, the Foundation Raspberry Pi decided to not activate the SSH connections by default. But in order not to block people opting for an installation headless, without screen and without keyboard therefore, the Foundation has put in place a simple and fast solution to activate the SSH. You simply have to create a file named ssh in the Boot partition (the file does not expect any extension).

When the Pi is first started, it checks if the file exists and activates the SSH accordingly.

Connect the Raspberry Pi to your Wi-Fi box

The SSH connection is now possible but there is still a step to make the Raspberry usable remotely, headless. Of course, I’m talking about making the connection to the box, which is paramount to using the Pi with SSH.

First, if you want to connect the Raspberry Pi via Ethernet, you can go directly to the next section because no configuration is required.

Here we need a Raspberry Pi 3b or a Raspberry Pi Zero W but the solution remains the same with other models (Pi 1B, 2B, Zero).

In order to configure the Wi-Fi connection when starting the Pi, we will edit thewpa_supplicant.conf file , located in the /etc/wpa_supplicant/ folder.

The file contains the following:

Ctrl_interface = DIR = / var / run / wpa_supplicant GROUP = netdev 
update_config = 1 
country = GB

We will add the following lines via the Note app (or any other text editor, such as SublimText, NotePad, etc.).

Network = { 
        ssid = "BoxName" 
        psk = "Security" 
        key_mgmt = WPA-PSK 
}

In the ssid line , you will replace BoxName with the name of your box, for example , Livebox-5678 . For the psk field , this corresponds to the security code of your box, so replace Security by the key of your box. And finally the last line corresponds to the security type of your box, usually WPA.

If you want to know more about the Wi-Fi connection, we have an article about it that you can find by following this link .

Set up a static ip for your Raspberry Pi

In order to know the ip that the Raspberry Pi will take, we will give it a static ip. For this we will modify the file dhcpd.conf located in the /etc/folder.

To modify the file, use the same software as to configure the Wi-Fi.

Once in the file, go to the last line and add the following content

eth0 
static ip_address = 192.168.1.100 / 24 
static routers = 192.168.1.1 
static domain_name_servers = 192.168.1.1 

wlan0 interface 
static ip_address = 192.168.0.100 / 24 
static routers = 192.168.1.1 
static domain_name_servers = 192.168.1.1

Let’s take a look at all this, here interface eth0 corresponds to a connection of wired type and interface wlan0 to a Wi-fi connection . So you have to choose the one that corresponds to your setup.
Static ip_address is used to indicate the ip that your Raspberry Pi will have once started. Generally the ip is of type 192.168.1.x , replace the x with the value of your choice, be careful not to conflict with other devices .

For static router and static domain_name_servers , this is usually the ip of your box, which is 192.168.1.1 .
You only have to save the file.

 

The SD card is now ready to be inserted into the Raspberry Pi and to start it without a screen and without a keyboard . All you have to do is login SSH to finalize the configuration of the Raspberry Pi (change of passwords, extend the SD card, etc).

Share
Newsletter
Author:
Raspbian France
Join the Raspberry Pi community
A $35 computer, already sold at 10 millions copies
BUY THE NEW RASPBERRY PI 3
Related tutorials
Install Nginx Raspbian, and accelerate your Raspberry web server Choosing accessories for your Raspberry Pi 2 Create your home radio transmitter with raspberry pi How to create a SD card for your Raspberry Pi using command line on GNU / Linux Install WordPress on a Raspberry Pi (with Nginx).
No Comments
Share
Suscribe to Newsletter
Inscrivez-vous à la Newsletter.
Vous avez aimé cet article ?
Inscrivez-vous et restez informé !