How to Connect via SSH to a Raspberry Pi

Raspberry Pi login via SSH with IP Address

Hey there! Some links on this page may be affiliate links which means that, if you choose to make a purchase, I may earn a small commission at no extra cost to you. I greatly appreciate your support!

In this tutorial, you will learn how to enable SSH on a Raspberry Pi and connect to it via SSH. This is especially useful when trying to access a headless Raspberry Pi where there is no desktop environment.

Watch this video for some a more detailed walkthrough of the steps in this tutorial.

1. Image Your Raspberry Pi SD Card

The first step is to image your SD card with Raspberry Pi OS. Download the Raspberry Pi Imager here, and install it on your computer.

Open the Raspberry Pi Imager and click on CHOOSE OS. You can pick any flavor of Raspberry Pi OS, but we will be using the Lite (32-bit) version with no desktop environment which is under the Raspberry Pi OS (other) section. This is the first option in the screenshot below.

Raspberry Pi operating system list

Next, insert an SD card that’s 4 GB or bigger and click on CHOOSE SD CARD. Pick your SD card from the list.

Finally, you can click on WRITE. This will erase everything on the SD card.

The process will take a few minutes. When it’s done, physically take the SD card out of your computer, and re-insert it. The name of SD card should be called boot.

2. Enable SSH Access on Raspberry Pi

Since the Raspberry Pi OS is headless which means there is no desktop environment, we will have to access it via SSH. If you’re not familiar with SSH, think of it as a way to login to your Raspberry Pi from your computer.

In order to enable SSH access on your headless Raspberry Pi, simply create an empty file called ssh at the root of your SD card. If you are on Mac, the follow command will do the trick:

touch /Volumes/boot/ssh

3. Set Up WiFi on Raspberry Pi

Again, because your Raspberry Pi is headless, we need a way to automatically have it connect to Wifi when it starts up so we can login via SSH. In order to do this, we need to create a file at the root of the SD card called wpa_supplicant.conf. Replace WIFI_NAME and WIFI_PASSWORD with the actual name and password for your WiFi network.

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


When you’ve done that, eject the SD card from your computer and insert it into your Raspberry Pi.

4. Find the IP Address of Raspberry Pi

Apply power to your Raspberry Pi and wait a few seconds for it to boot up.

In order to connect to the Raspberry Pi via SSH, we need to determine its IP address. To do this open Terminal on Mac/Linux (or Command Prompt on Windows) and  execute the following command.

ping raspberrypi.local

If your Raspberry Pi successfully connected to the WiFi network with the credentials you provided, you should see output similar to this.

Determine Raspberry Pi IP address

In this case, the IP address of the Raspberry Pi is

5. Login to Raspberry Pi vis SSH

Now that we know the IP address of the Raspberry Pi, we can login via SSH.

On a Mac, open terminal and use the SSH command and IP address to login. If you are using Windows, please follow this tutorial to login to your Raspberry Pi via SSH with Putty. Of course, use the IP address of your Raspberry Pi.

ssh pi@

The default Raspberry Pi username is pi and the default password is raspberry.

When you are logged in, your terminal window will look similar to this.

SSH access on Raspberry Pi

6. Give Raspberry Pi a Hostname (optional)

If you’d like, you can assign your Raspberry Pi a hostname instead of using the IP address directly. In order to map a hostname to the IP address of your Raspberry Pi, you simply need to edit the hosts file on your computer.

For Mac and Linux users, you can watch the video below, and Windows users can learn how to edit the hosts file here.

YouTube video

Next Steps: Raspberry Pi Website Hosting

Now that you have SSH access, you have a few different options for hosting a website on your Raspberry Pi. I also have these other Raspberry Pi tutorials for you to check out next.

For you convenience, the video below will walk you through the steps in this tutorial.

YouTube video


Meet Tony

Tony from Tony Teaches Tech headshot

With a strong software engineering background, Tony is determined to demystify the web. Discover why Tony quit his job to pursue this mission. You can join the Tony Teaches Tech community here.

Leave a Reply

Your email address will not be published. Required fields are marked *