How to ssh into a Raspberry Pi

raspberry pi
networks
Author

Salman Faris

Published

May 17, 2025

I have a spare Raspberry Pi 4 that my brother Zubair gave to me almost 5 years ago. I rarely get gifts in my family, so it’s something that I quite treasure. I just never had the time to do anything meaningful with it because I was so busy with first university, then starting a new job… until now.

In the coming weeks, I’ll be looking into hosting an Apache server on a Pi and possibly do something more (I have some interesting ideas in plan). The first step to all that is to be able to setup the Pi and ssh into it - I don’t want to use an extra monitor just for using my Pi so we shall look at how to do a headless setup for our Pi.

Before we proceed, here’s a list of hardware that we will need:

Flash the Raspberry Pi OS onto the SD card

We can use the Raspberry Pi Imager to do this. Download the imager here.

Once you have the Raspberry Pi Imager downloaded, plug in your SD card into your machine (i.e. your Mac/Windows/Linux) and verify that your machine finds it.

Then open the Imager, choose your Raspberry Pi device, mine is a 4. Then choose the Raspbian 64 OS and proceed to use your SD card as your storage.

When you hit next, it will ask if you want to apply OS customisation settings. This is an important step, so click EDIT SETTINGS.

Here, you can set a username and password if you don’t want the default username:pi and password:raspberry. Most importantly you want to enter your wifi SSID and password here so that your machine can find your Pi over private IP. On the services section, you can let the default settings which basically says to use your Pi authentication to allow for ssh.

Now wait maybe around 45 minutes for the Imager to write (or overwrite) your SD card and verify the installation.

Boot the Pi

The next step is pretty straightforward. Insert the SD card into the Pi and plug in the power cable. You want to wait maybe like 5 minutes for your Pi to boot and connect to your wifi network that you have setup during flashing.

Find the Raspberry Pi IP address

Now that it’s hopefully connected to your wifi network, go back to your machine. You now have two options to find your Pi’s private IP address:

  1. Manual router approach: Find all the connected devices on your router’s dashboard and look for a hostname like raspberrypi or something that has the word Raspberry or Pi in it.
  2. nmap: Open your terminal. Use the network scanner nmap. Find your IP by running something like ifconfig | grep en0 -A 2. Infer your IP range from your private IP to get something like 192.168.0.0/24. Then run sudo nmap -sn 192.168.0.0/24 and find anything that has the word Raspberry on it.

In both methods, get the private IP address, something like 192.168.0.XXX and then export this as a variable export PI_IP=192.168.0.XXX in your terminal.

ssh into your Pi

Optional but try to ping your Pi. What happened to me was that I copied the wrong IP address when I was network scanning. So send three packets by running ping -c 3 $PI_IP. If this is successful, it’s time to ssh into the Pi.

You can ssh into your pi by running ssh pi@$PI_IP. If you didn’t set a username and password, your username is pi and your password is raspberry. Change this after successfully ssh-ing into your Pi using the passwd command. Otherwise, use the username and password that you have setup during flashing.

And there you have it, your are now in your Pi!

In the upcoming posts, we shall look into how we can host a server on our up-and-running Pi.