Setting up a Headless Raspberry Pi

Goal:

Our goal is to set up a Raspberry Pi to be headless, or without a monitor, that we can connect to through SSH. This will be very useful for setting up Raspberry Pi Zero W boards because these use mini HDMI for display out, and you need a USB-OTG adapter to connect a mouse and keyboard. You can set up any Raspberry Pi board in this way.

Materials:

  1. Raspberry Pi that can connect to the internet (using built-in Wi-Fi or a dongle)
  2. Good quality SD card
  3. Micro-USB power supply for powering the board

Software Used:

  1. PuTTY (or another SSH client). PuTTY
  2. Win32 Disk Imager

Step 1:

The first step is to download the operating system the Raspberry Pi will use, I chose to use Raspbian, the official Raspberry Pi operating system. You could use another operating system, but the steps to set up SSH may be slightly different. Get Raspbian. Since we are setting up our Pi to work headless, we can choose the "lite" version of whatever operating system because we do not need the desktop features. This saves space on our SD card, too.

Step 2:

Next, use Win32 Disk Imager to write the operating system to the SD card.

Windows thirty two disk imager.

Select the downloaded operating system image with the blue folder icon.

Make sure the correct drive is selected!

Click "Write" to write the operating system to the SD card. This will take a while.

Step 3:

Next, we need to create a file that will let us use SSH on the Raspberry Pi. To improve security of connected devices, your Raspberry Pi operating system will most likely have SSH disabled by default.

You may need to eject your card and re-insert it into your PC to find the /boot directory.

Rasbian needs an empty, extensionless file named " ssh. " in the /boot directory of the SD card to enable SSH. To do this on Windows, open Notepad and save a blank file with the name " ssh. " and choose All Files for the Save as type. Move this file to the /boot directory. note: the " . " at the end of ssh is important when saving the SSH file otherwise Windows will make this a text file, even if we choose All Files for the Save as type.

Congratulations, you are now ready to plug in your Raspberry Pi!

Step 4:

Now we will plug in the Raspberry Pi to a power supply. While the Raspberry Pi boots for the first time, we need to find the IP address of the Pi. There are many ways to do this, I logged into my home router to look at the connected devices because this was easiest for me to do.

This is what I see when I look into connected devices on my home router.

What we are looking for is the IP Address so we know what to SSH to later.

Here, my Raspberry Pi's address is 192.168.1.116. Your Pi's address will be similar to this, because devices on your local network are going to probably start with 192.168.1

Router connected devices.

Step 5:

The next step is to open our SSH client and attempt to log into the Pi.

This is the main screen of PuTTY. All we need to do to connect to the Pi is put the IP address.

If you want to save the IP address to connect easily in the future, enter a name for the connection and click Save.

In the future, we can open a connection to this IP address by double-clicking the saved session name.

Putty main screen.

If you see this, congratuations! You have now connected to your Raspberry Pi over SSH.

The next steps are to change the default password and set a static IP address.

The default login for the Raspberry Pi is user: pi, password: raspberry

Blank login screen.

Step 6:

The next step is to change the default password for the Raspberry Pi. This is important to do because anyone on your network could log in to the Raspberry Pi.

To change the password, use the command passwd and follow the prompts.

Change the password.

Step 7:

The last step for our SSH setup is to make sure the Raspberry Pi has a static IP address so we always know where to connect to in the future, and we can save a SSH connection.