Install Raspberry Pi OS, Set Up Wi-Fi, Enable and Connect with SSH

In this tutorial, you’ll learn how to get started with the Raspberry Pi by installing the operating system, setting up Wi-Fi, and enabling and connecting with SSH. You can configure everything without the need for an extra monitor, keyboard, or mouse—the Raspberry Pi will be running headless.

Install Raspberry Pi OS, Set Up Wi-Fi, Enable and Connect with SSH

Updated 18 December 2023

Table of Contents

In this article, we’ll cover the following:

  1. MicroSD Card
  2. Installing Raspberry Pi OS
  3. Connecting the Raspberry Pi to the Internet
  4. Enabling SSH
  5. Connecting via SSH to the Raspberry Pi

1) MicroSD Card for Raspberry Pi

The Raspberry Pi is a computer and like any other computer, it needs an Operating System (OS) installed.

The Pi doesn’t have built-in storage, so you’ll need a microSD card to install your OS. We’ll install the operating system on the microSD card. I recommend using a microSD card class 10 with at least 16GB of memory.

16 GB microSD card

2) Installing Raspberry Pi OS

We’ll install the Raspberry Pi OS (previously called Raspbian), which is the official Raspberry Pi operating system.

1) Start by connecting the microSD card to your computer.

2) Go to the Raspberry Pi Software page.

3) Select and download the Raspberry Pi Imager (a tool to flash the OS on the microSD card) for your computer’s operating system.

Download Raspberry Pi Imager

4) Click on the downloaded file to install the Raspberry Pi Imager.

Raspberry Pi Imager Setup

5) When the installation is complete, the Raspberry Pi Imager will open.

Raspberry Pi Imager Software

6) Click on Choose Device and select the Raspberry Pi board you’re using.

Raspberry Pi Imager Choose Device

7) Click on Choose OS to select the Operating System. Select the Raspberry Pi OS (32-bit) or (64-bit).

Raspberry Pi Imager Choose OS

8) Choose storage. You must choose the microSD card where you want to install the OS.

Raspberry Pi Imager Choose Storage

9) Click Next. Next, you’ll be asked if you would like to apply customisation settings. Click on Edit Settings to set up the Wi-Fi credentials, and enable SSH.

10) Under the GENERAL tab, you can set an hostname (the default will be raspberrypi), user, and password, and set Wi-Fi with your local network credentials, so that you can connect to your Raspberry Pi using Wi-Fi later on. You can also select your timezone.

Don’t forget to set your Wireless LAN country!

11) Then, click on the SERVICES tab and enable SSH with password authentication.

Raspberry Pi Imager Enable SS

12) Click Save. You’ll be asked if you want to apply the OS customisation settings. Click YES.

Raspberry Pi Imager apply costumisation settings

13) Finally, you’ll be asked if you want to continue. Click YES to start burning the Raspberry Pi OS on the microSD card.

14) Wait a few minutes while it installs the Operating System.

Raspberry-Pi-Imager-Installing-OS

15) When the installation is complete click on Continue. It will eject the microSD card safely.

Raspberry Pi OS Write Successfull

15) Now, remove the card from your computer and insert it into your Raspberry Pi. Then, apply power to the Raspberry Pi to start it.

3) Connecting the Raspberry Pi to the Internet

If you’ve already set up the network credentials in the previous instructions, you can skip this section.

In this section, we’ll set up the Raspberry Pi to connect to the internet (your local network) when it first starts, without the need to connect a monitor, keyboard, or mouse (this is called headless).

Remove the microSD card from your computer and insert it again so that your computer can recognize the microSD card again.

1) Create a new file called wpa_supplicant.conf and paste the following.

country=PT # Your 2-digit country code
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
network={
    ssid="YOUR_NETWORK_NAME"
    psk="YOUR_PASSWORD"
    key_mgmt=WPA-PSK
}

Insert your 2-digit country code and the network credentials (SSID and password) of the network that you want the Raspberry Pi to connect to.

wpa_supplicant.conf File Raspberry Pi

2) Open the microSD card folder and move the wpa_supplicant.conf file there.

wpa_supplicant.conf file coppied to microsd card

4) Enabling SSH

If you’ve already enabled SSH in the previous instructions, you can skip this section.

To access your Raspberry Pi remotely (via a computer on your local network) so you don’t need to connect a monitor, keyboard, or mouse to the Raspberry Pi, you need to enable SSH. SSH allows you to connect to your Raspberry Pi remotely from another machine and access the command line.

To enable SSH, you need to create a file called ssh (without any extensions) on the boot folder of the microSD card.

1) You can click here to download the ssh file.

2) Move that file to the boot folder of the microSD card.

ssh file microsd card

When the Raspberry Pi starts up, the OS will find the ssh file and will automatically activate SSH.

Now, safely eject the microSD card from your computer and insert it on the Raspberry Pi. Then, power up the Pi using a 5V DC power source.

5) Connecting via SSH to the Raspberry Pi

SSH (which stands for secure shell) is a method of establishing a communication with another computer securely. All data sent via SSH is encrypted. SSH is based on a Unix shell, so it allows you to access your Raspberry Pi files from a remote machine by using terminal commands.

This part is divided into two sections: 

A) Windows

To communicate with the Raspberry Pi via SSH, you need a software to handle SSH communication. We’ll use PuTTY. You need to install it on your computer if you haven’t already.

Downloading PuTTY

If you use Windows, you need to download and install a free application called PuTTY. Here’s how to install it:

1) Open your web browser and go to www.putty.org

2) Download PuTTY. We recommend downloading the putty.exe file.

Download PuTTY

3) Run the putty.exe file to execute the software.

Connecting to the Raspberry Pi via SSH

With PuTTY installed, power up your Raspberry Pi and follow the next steps (wait at least five minutes before connecting if this is the first time the Raspberry Pi is booting up to give some time to load the operating system):

1) Open PuTTY.

2) Select/enter the following options:

  • Host Name: raspberrypi *
  • Port: 22
  • Connection type: SSH

* raspberrypi is the default hostname. If you’ve inserted a different hostname in the installation process, you should use that instead.

Connect to Raspberry Pi via SSH

3) Click Open.

4) When you connect to your Raspberry Pi for the first time, you’re prompted by a message warning you that you’re attempting to establish a connection with an unknown host. Simply click No to proceed.

Connect to Raspberry Pi SSH Warning Message

5) Now, you need to login to your Raspberry Pi using the username and password you set on the installation process.

If PuTTY warns that the hostname doesn’t exist, you might need to restart your router so that it assigns an IP address to your Raspberry Pi.

On the new window that opens, type your username and hit Enter.

6) Then, enter your password and hit Enter. You won’t see any characters showing up on the window while you type the password.

Login Raspberry Pi SSH

Now you have an SSH communication established with your Raspberry Pi. This will be useful to install software on your Pi, run your programs, create folders or files, etc…

I recommend reading my Raspberry Pi Cheat Sheet with Basic Linux Commands.

Shutting Down

To shut down your Raspberry Pi, simply type this command on the command line:

pi@raspberry:~ $ sudo poweroff

The SSH connection will be shut down right after.

B) Mac OS X/Linux

SSH (which stands for secure shell) is a method of establishing a communication with another computer securely. All data sent via SSH is encrypted.

SSH is based on a Unix shell, so it allows you to access your Raspberry Pi files from a remote machine by using terminal commands. It has grown to be one of the most popular methods for communication between different devices.

Establishing an SSH Communication

In Mac OS X and Linux, you can use the default Terminal window to establish an SSH communication, because SSH comes in all Unix-based OSes. Follow these steps:

1) Boot up your Raspberry Pi.

2) Open a new Terminal window.

3) Type the following command:

$ sudo ssh pi@raspberrypi

or:

$ sudo ssh [email protected]

Note: if you defined a different hostname and username rather than raspberrypi and pi, you should use those instead.

4) Enter your computer password (so you can run a sudo command), and type yes.

5) When you’re asked to type a password for your Raspberry Pi type the password you’ve set previously, press Enter/Return.

When you connect your computer to your Raspberry Pi for the first time, you’re prompted by a message warning you that you’re attempting to establish a connection with an unknown host. Simply click OK to proceed

Your Terminal window should look like the Figure below:

Now you have an SSH communication established with your Raspberry Pi. This will be useful to install software on your Pi, run your programs, create folders or files, etc…

I recommend reading my Raspberry Pi Cheat Sheet with Basic Linux Commands.

Shutting Down

To shut down your Raspberry Pi, simply type this command on the command line:

pi@raspberry:~ $ sudo poweroff

Wrapping up

In this tutorial, you’ve set up your Raspberry Pi to run headless. You’ve installed the Raspberry Pi OS, set up Wi-Fi, and enabled SSH so that you can access the Raspberry Pi command line from another machine on the same network. Finally, you established an SSH connection with the Raspberry Pi.

I hope this guide was useful. You’re now able to easily connect via SSH to your Raspberry Pi and send Linux commands (read Learning Basic Linux Commands – Raspberry Pi Cheat Sheet).

Looking for Raspberry Pi electronics projects? Check out our book: 20 Easy Raspberry Pi Projects Book



Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »
Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »

Enjoyed this project? Stay updated by subscribing our newsletter!

25 thoughts on “Install Raspberry Pi OS, Set Up Wi-Fi, Enable and Connect with SSH”

  1. When entering user = pi and password = rasberry does not allow me access and I already try a thousand times that may be happening.

    Reply
    • Hi Alexis.
      The passowrd is raspberry and not rasberry.
      Have you modified any settings in your operating system?
      Those are the correct credentials.
      Regards,
      Sara

      Reply
  2. I guess it’s an update; very useful especially for Wifi setup connection instead of using “sudo raspi-config” instruction, thanks a lot.

    Reply
    • Hi.
      Yes, this is an update.
      Previous instructions were for Raspbian. Now, there’s Raspberry Pi OS.
      Additionally, we now include the instructions to set up Wi-Fi on boot without the need to connect a monitor or to connect via ethernet first.
      Regards,
      Sara

      Reply
      • Hi Sara,

        In the latest release, the default user “pi” has been removed 🙁 So there is no other way than either using the “Raspberry Pi Imager” (and clicking the setup icon to set a user and password aside from enabling ssh), or otherwise first connecting a screen and keyboard to create a username and password there.

        Reply
  3. I think there is a mistake in the instructions. Attempting to connect to connect to the raspberry Pi via ssh using: $ sudo ssh pi@raspberrypi
    gave the error: Could not resolve hostname raspberrypi: nodename nor servname provided, or not known

    Instead, I used: ssh [email protected]

    sudo was not necessary

    Reply
  4. A neat trick I learned recently:

    CTRL-SHIFT-X in rpi-imager opens a dialog where a lot of stuff can be set, even before burning an image. Like hostname, password, wifi settings, ssh enable and localization. Don´t know why they forgot the button for this.

    Reply
  5. Hi,

    Great content, as always! There is also the possibility to do some of the instructions in the RPI IMAGER directly, by accessing to the advanced settings by pressing Ctrl-Shift-X. There we can configure hostname, ssh, Wi-Fi, among others…

    Great work!

    Reply
  6. It turns out there’s a good reason for using sudo with ssh initially. I redid the installation since I’m still having trouble getting MQQT to run in any mode other than local. When I tried to use ssh pi@raspberrypi the logging balked because the fingerprint didn’t match. I could: A. try adding the key to /users//.ssh/known_hosts or B: just use sudo ssh and let the system take care of the problem. After failing at A I tried B and it worked just fine.

    I think you folks do an amazing job at making this inherently complicated stuff work at the easiest level for all users. Now if I can just get MQTT dumbed back down to the pre-2.0 version less secure level that works so well for my simple needs.

    Reply
  7. Dobrý, chcel by som sa opýtať v čom môže byť problém ak pri snahe pripojiť sa na raspberry pi cez putty vypíše že nebolo možné sa pripojiť k raspbery, hosť neexistuje
    Ďakujem za odpoveď

    Reply
  8. Hi Sara,
    Thank you for the very good tutorials, I’ve been a fan of your website for a very long time. Not only for the Raspberry, but also for the ESPs, it has often taken me one step further.
    After trying unsuccessfully to assign a static IP to my RaspberryPi, I’m in the process of setting it up again.
    So it remains exciting whether it works now. But maybe you would have time and desire to write something about it, I would be happy about it.
    A hostname is good, but addressing the Raspberry with an IP would be quite friendly, especially for Tasmota and ioBroker
    Thank you again and have a great summer
    Are you from Portugal, I ask because I love the country and have already hiked from Faro to Lisbon by bike and on foot from Porto to Santiago de Compostela.
    Maybe this year it works again.
    Adeus

    Reply
  9. At the beginning you say “The Pi doesn’t have built-in memory, …”
    It does have built-in memory.
    I think you should say “The Pi doesn’t have built-in storage or a disk,…”

    Reply
  10. I updated my raspberrypi and did the binary update. I now cannot access the “settings” in raspberry pi. It goes to error and puts me back on the settings screen. So, I can’t adjust audio Bluetooth or anything on the settings screen. Anyway to revert back to what it was before the update?

    Reply
  11. Nice Job
    but there is a problem
    rpi 4 image
    I will use IP-adress 192.168.1.164
    Putty and SSH find can find that adress an i can reach that system in this manner,
    but I like to use that adress in my browser (chrome)
    that is impossible!! —>connection refused
    Do you have a suggestion?
    gr
    Dick

    Reply
  12. Hi Rui,
    does the RasPi provide his own network in this project where the ESP connects to?
    In other words: Is the RasPi a standalone MQTT-server (broker), or is my local network still in use for the MQTT tasks?
    Regards
    Oli

    Reply

Leave a Comment

Download Our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.