9-Steps Raspberry Pi Headless Setup with Ubuntu 21.04
Tags: raspberrypi, ubuntu, headless
Published: 2021-07-26 08:43:02

Hold-on, if you don't have a Raspberry Pi, yet, I can recommend these on [Amazon](https://amzn.to/3lzRCYt).


#Step 1: 🍓 Download Raspberry Pi Imager
Raspberry Pi Imager is used to install Operating System to the microSD card. This software works for MacOS, Windows and Linux (click here to download).

#Step 2: 🔌 Plug your microSD card to your computer
Depending on your computer setup, you will need a microSD Card reader.
Being on a Mac, I’m using this docker you can buy on [Amazon](https://amzn.to/3FPBXNS).

#Step 3: 🔥 Flash the Card with Ubuntu 21.04
Launch the Raspberry Pi Imager tool.
![Raspberry Pi Image Welcome Page](https://miro.medium.com/max/700/1*pkeal1DbiCQBmbN7OQioVw.png)

Depending on the Raspberry Pi you have, you will need to choose the right OS (64-bit vs 32-bit). In this case, I’m using the 64-bit version).

![Raspberry Pi Image Welcome Page](https://miro.medium.com/max/700/1*y6LUCRWmqfS6RSVMwuBt9A.png)

Now let’s choose the SD Card (be careful here, to select the right one!).

![Raspberry Pi Imager](https://miro.medium.com/max/700/1*WshpU5tcshqTFuheTvjKTQ.png)

Now we are all set, and we can click on Write button to actually flash the SD card.

![Raspberry Pi Imager](https://miro.medium.com/max/700/1*xBKvGgm62CP9V3rO9Sw13Q.png)

![Raspberry Pi Imager](https://miro.medium.com/max/700/1*SUSYICYWTwRT09LWLAsyGQ.png)

After a couple of minutes (writing & verifying), your microSD card will be flashed.

![Raspberry Pi Imager](https://miro.medium.com/max/700/1*rjZQGjYagViRgtsDSA0acA.png)

#Step 4: 📡 Setup WiFi connection

Eject, and re-plug the microSD card to your computer.

Now, open the microSD card directory, and look for the “network-config” file (in the root folder).

Open it with your favorite IDE. I’m using Visual Studio Code in this tutorial.

![network-config in the root directory](https://miro.medium.com/max/700/1*zudGOT_Wci9k060Mzv43rg.png)

The initial content of this file should look like this:

```
#[...] some comments
version: 2
ethernets:
  eth0:
    dhcp4: true
    optional: true
#wifis:
#  wlan0:
#    dhcp4: true
#    optional: true
#    access-points:
#      myhomewifi:
#        password: "S3kr1t"
#      myworkwifi:
#        password: "correct battery horse staple"
#      workssid:
#        auth:
#          key-management: eap
#          method: peap
#          identity: "me@example.com"
#          password: "passw0rd"
#          ca-certificate: /etc/my_ca.pem
```

As you can see, a specific section about wifis is already written, and commented.

Now, change this file such as:

```
version: 2
ethernets:
  eth0:
    dhcp4: true
    optional: true
wifis:
  wlan0:
  dhcp4: true
  optional: true
  access-points:
    your_wifi_name:
    password: "your_password"
```

Save the file, and eject the microSD card properly from your computer.

#Step 5: 🏁 Start the Raspberry Pi

Now, we have a properly flashed microSD card, and a wifi connection, let’s plug back the microSD card into the Raspberry Pi, and switch it on.

#Step 6: 🏠 Identify your Raspberry Pi IP address

In order to connect us to our Raspberry Pi, we need to define it’s IP address.

Several methods can be used here. The easiest one consists in connecting to your internet provider box, and try to find the new Ubuntu Server from our Raspberry Pi.

Here we are:

![UBUNTU Machine IP Address on local network: 192.168.1.45](https://miro.medium.com/max/374/1*r6wUKIxqhLu35m3d-pK2Ag.png)

#Step 7: 🛰️ SSH connection

##Hold on, what is SSH connection?
According to Wikipedia: SSH is typically used to log into a remote machine and execute commands
Now, open a Terminal command.

```
ssh ubuntu@192.168.1.45
```

ubuntu is the default login, and the @192.. is the IP address we identified in the previous step.

```
The authenticity of host '192.168.1.45 (192.168.1.45)' can't be established.
ECDSA key fingerprint is SHA256:xxxxxx.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
```

Type Yes.

The default password is ubuntu as well. You will be required to change the password directly after first sign-in.

Once the new password set, the connection will be automatically closed. You will have to restart the ssh connection, using the new password you defined.

#Step 8: 🍿 Enjoy

You are all set.

#Comment ☝
- Don’t forget, that we didn’t define a static IP address for our Raspberry Pi. It means, that the IP address will be dynamically (DHCP) changed over time.
- If you need a static IP, please check my next article (soon).

#Post Scriptum #1
If you like this kind of blog posts, don't hesitate to check my blog [Catchtheblock.com](https://catchtheblock.com).

#Post Scriptum #2
If you prefer a good video detailing this process, I recommend watching this one 
👉 https://www.youtube.com/watch?v=dJTqd90bwsI