Setup the Raspberry Pi Zero with SSH remote access

When you buy your Raspberry Pi, directly out-of-the-box, the software part is not already installed. To be able to use it, you need to install an Operating System (OS) which will allow you to interact with it. In this article, we will see how to install the official Raspberry OS “Raspbian” Lite version with the tiny Pi Zero version.

What you will need to do so:

  • an empty 8GB SD Card for Raspbian Lite version or higher;
  • the .zip file which contains the OS, you can download it here;
  • Balena Etcher, a small software which will allow you to flash the SD card with the system;
  • a Raspberry Pi;

Once you have downloaded Balena Etcher and the OS here, you can insert the SD card into your computer.
Warning: be sure that your SD card is empty before doing the following manipulations. All files stored in the SD card will be definitively lost once the card will be flashed !

Open Balena Etcher, it should look like this:

The interface is quite simple:

  1. First, you select the .zip Raspbian image;
  2. Then, you select your SD card (be sure to select the right one, in case you have multiples devices connected to your computer);
  3. Flash !

Notice that you should have administrator rights on your computer to be able to flash.

Flash is on-going.

If your card has been automatically ejected, remove it and put it back. Now, you can see that your device is flashed and 2 partitions appear in your file explorer.

One partition called “boot” and another one that Windows cannot read.

The “boot” partition that we can access will be useful because we will be able to setup the default Wi-Fi configuration and to enable remote access.

Wi-Fi default configuration

In Raspbian (and others Unix systems), there is a service called “wpa_supplicant” used to configure wireless networks.

We will add a default profile to let know “wpa_supplicant” has to connect automatically to the wireless network. The template file that we will use is the next one:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

You can open a notepad and copy/paste it. The file has to be saved with .conf extension file in the root folder of “boot” partition. Then, you have to replace “wifi_network_name” and “password” by those of your network.

At the first startup, the system will look for this file and will apply this configuration to connect to your network.

Activate SSH

Secure Shell is a protocol which can establish an encrypted connection, so secured (we talk sometime of a tunnel), on a network between a client an a server.

This protocol will allow to remotely access to the Raspberry with a command-line interface. To activate it, you have to create an empty file named “ssh“, without extension and put it in the “boot” partition.

Some times ago, Secure Shell (SSH) was activated by default on installation but it implied some security matters. If you are not behind a firewall like the one of your router or if you don’t change the default “pi” account password, anybody could remotely take control of your Raspberry. We will see further how to change the password.

Connect remotely to the Raspberry

To establish a connection, we will use a client which will allow us to communicate with the server (the Raspberry). It is called PuTTY and you can download it here.

The installation is quite simple. Then, when you open it, you should see:

What is interesting us, is the “Host Name” where you have to put the IP address of your Raspberry on the network. To figure out the IP address, go to the home page of your router, the default host name is “raspberrypi”. Refer to the manual of the router if you have some issue to access to the interface.

When you have found the IP address, type it in “Host Name” field in PuTTY, be sure that the connection type is set to “SSH”, and then click on “Open”. You should see a black window with pending for a “login as”.

NOTE: if you have a message asking to put in cache a key, just confirm.

The default credentials are “pi” for the login and the password is “raspberry”. If you don’t see your password or even asterisk when you are typing it, it is normal.

That’s all ! I also recommend you to change the default password for security reason. To do so, just type “passwd” in the command line and follow the instructions.