Simple Raspberry Pi setup tutorial
This tutorial covers the intial setup of a Raspberry Pi. It is definitely not exhaustive, but it will suffice for simple applications.
Some links will be provided for the ones interesting of getting their install to the next level.
You will need :
- Raspberry Pi;
- Larger than 8Gb micro-SD card for the Pi (“class 10 cards of any brand are preferred);
- A computer with a memory card reader;
- Internet connection( depending on what use you will make of the Raspberry).
Topics covered :
- Installing an operating system (Raspbian)
- Connecting to the Raspberry with SSH (optional)
a. Enabling SSH
b. Setting up WiFi headlessly
c. Use SSH to connect to the Pi
- First boot
- Basic security measures (optional)
Flashing Raspbian on the SD card
Before powering up the raspberry, we must install an operating system. The most common OS for raspberry is a modification of debian-linux called Raspbian.
Note : This tutorial is based on Raspbian Stretch Lite as it will rely on SSH and setup using the terminal.
If you want to plug your raspberry to a monitor and use the GUI, download the “desktop” and then use the terminal to input the instructions.
Download and install Balena Etcher as well. This tool will help you flashing Raspbian on the SD card.
Flash the SD card
- Insert the SD card in the reader
- Launch Etcher on your computer
- Select the Raspbian image you just downloaded
- Etcher should find automatically the SD card
- Flash the SD card
If you plan to use the GUI and wire the raspberry to a monitor, keyboard and mouse you are done. Just insert the SD card and plug the power to the Pi. It will boot normally and you will be able to use it like a regular computer.
If you plan to use SSH to connect to the Pi using another computer, follow the next steps.
Connecting to the Pi with SSH (optional)
SSH connection allows you to control the Pi from an other computer on the same network or even from outside your home (providing you opened some ports in your router’s firewall). For security measures SSH is now disabled by default on fresh install of Raspbian.
Therefore, before booting the Pi for the first time, we need to enable SSH (otherwise it will not be possible to control it). If you want to connect the to Pi over WiFi, you also need to provide it with the information for it to connect to the network.
First of all, check that you see the SD card on your computer (usually Etcher ejects it after flashing the OS). If you do not see it, just remove it from the reader and put it back in. You should now see a
boot partition appearing.
To enable SSH, simply create a file called
ssh with no extension using any text editor and place that file in the
boot partition of thre SD card. That’s it, SSH is now enabled.
You can find more information Secure Shell (SSH) access on the Raspberry foundation website.
Before connecting to the Pi from your device, you need to make sure the Pi is on the same network as you. If you are planning to wire the Pi using a LAN (ethernet) connection, this step is not necessary as it will be physically connected to the network.
If you plan to connect using WiFi (either with a USB dongle or with the built-in WiFi antenna of the Raspberry), you must first give the raspberry the login information of your network.
To do that, use any text editor to create a file called
wpa_supplicant.conf and type the following :
<xxx> parts with your login credential (replace the
> as well). The country code you should be using is the Alpha-2 ISO Code of your country. See Wikipedia for the list of codes.
In the end, the file should look like that
Put that file on the
boot partition of the SD card, along the
ssh file created previously, and that is it. You may now insert the SD card in the raspberry and power it up.
Note : If you want to avoid writing the WiFi password in plain text on the raspberry, you could also use an 32 byte encrypted version. However, that manipulation is a bit more complicated for first time users and therefore beyond the scope of this tutorial. You can find more information on that using the Raspberry foundation website.
SSH to the Pi
For Linux and Mac users, you can now directly connect to the Pi without even knowing it’s IP. Use simply
rasoberrypi.local as hostname (it only works if you have only one Pi on the network). Open a terminal and type in
For windows users, you must first download a SSH client. The most common one is Putty.
You will now have to find the local IP of your Pi. The easiest way is to go into your router settings (usually the credential are located on a label sticked to the bottom of the router). The router opening page should give you the local IP of all your devices, including the Pi.
Other methods are also described on the Raspberry foundation website.
When you have your Pi’s IP, open Putty and enter the IP in the
hostname field, then click
Open. Accept the security warning and that is it.
The Pi will now ask for login and password information. The default values are
Changing the timezone
The first good thing to do is to define the timezone of your raspberry. Some application depend on time constants and will work better if you set it correctly.
sudo raspi-configto get in the configuration menu of the raspberry. Then navigate to the
Localisation Options and select
Change Timezone. Follow the instructions to select the timezone that corresponds to the location of your Pi.
Set up a static local IP
A static IP on your local network will make sure your router always assign it the same IP to the device. This will facilitate the connection (as you will not need to check your Pi current IP each time) and it is mandatory for reliable remote access.
The simplest and most robust way to do it is to assign the Pi a static IP in your router configuration. If you can do it, the rest of this section is not necessary. However, you may not always be able to do it on the router level. So we must make sure the Pi always ask the router for the same IP instead.
In that case, modify the dhcp configuration file with
sudo nano /etc/dhcpcd.conf
and enter the following at the bottom of the file
Make sure you rename the addresses accordingly to your needs:
ip_address should be the one desired for the Pi, the two others are the one of your router.
Security hardening (optional)
There are many ways to increase the security of your raspberry, but these are beyond the scope of this small tutorial. You can find a more complete explanation on the Raspberry website.
We will however see how to change the default username and password.
Changing the password
It is strongly advised to change the default password of your raspberry, as they are all the same by default and grant root access to your device. Changing password is as simple as typing in your terminal the command
Then typing the current one and entering twice the new desired one.
Changing your username
You can also change the username to make your raspberry even more secure. To do so, either type
sudo adduser <USERNAME>
OR, if you want that new user to have `sudo` (super-user) permissions
sudo adduser <USERNAME> sudo
You will be prompted to create a password for this new user. This user will automatically have a home directory at
If the new user you created has
sudo permissions, the default
pi user is no longer required and can be deleted using
sudo deluser -remove-home pi
This tutorial only covered the basics of the setup of a raspberry. If you need to increase the security, add fetures or change other advanced parameters, you will likely find that information in the Raspberry configuration documentation.
I hope this tutorial will help you setting up your raspberry and you will have as much fun as I do with it.
Tip in IOTA are always welcomed : XSTZVGRXPDEBVHL9ZFDBUBCZOAPNRSWZBMNACARQFMFXMLTEVCHHZHSLSH9FGYJIOZOXMNULGNNLJYEIDURJRDHN9W