This post may contain affiliate links. If you buy something through one of our affiliate links, we may earn an affiliate commission at no additional cost to you.

The Raspberry Pi is a computer that can do so much in such a small and discrete form-factor.

I’m going to show you how you can set up your Raspberry Pi to automatically enable SSH and connect to Wi-Fi without the need to configure this directly from the device, allowing you to use the Raspberry Pi without a keyboard or monitor connected.

Video Tutorial

Click here to display content from YouTube.
Learn more in YouTube’s privacy policy.

Getting Started

To get started, you’ll either need a new or existing Raspbian installation. I’ll be working with a new installation of Raspbian Lite that has been flashed and written to the card using Etcher.

To start off with, you’ll want to have your SD card plugged into your computer so we can save the necessary files to it.

Enabling SSH

Enabling SSH is straightforward. You’ll want to create a file named ssh within the boot directory of the SD card. It is important to ensure that this file does not have a file extension, or it will not work.

The easiest way to create this file will be to open Windows Explorer and browse to the boot directory. Now you’ll want to enable file name extensions within Windows Explorer, go to View at the top and check the File name extensions checkbox, this will allow us to check that the file we create does not have an extension.

SSH File in Directory
Creating a file named “ssh” will enable SSH when the Pi boots up

To create the file, right-click within the directory and select New > Text document. Select the all the “New Text Document.txt” placeholder text and replace it with “ssh”, ensuring that there is no file extension.

Adding Network Information

Now that SSH is set to be automatically enabled when the Raspberry Pi boots up, we’ll want to give it some network information so it can connect to the network over Wi-Fi. To do this, we’ll create another file in the boot directory.

Create a new file called wpa_supplicant.conf, this is where we will enter the network information so it can be imported by the Raspberry Pi when the system boots.

Within this file you’ll want to insert the following code:

If you don’t want to type all of this out, visit the written article linked in the description so you can copy and paste the code over.

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
country=<Insert country code here>

 ssid="<Network Name>"
 psk="<Network Password>"

You’ll also need to insert the ISO code of your country so that 5G networking will function correctly. You can find your country code on this handy list from Wikipedia, in my case I will need to add GB.

Network Configuration
The configuration file will be imported by the operating system when it next boots

This configuration file should work for most networks, but if you have a different or more complex setup, you may need to add extra parameters to your configuration file which can be found on the Raspberry Pi documentation.

Once you’ve entered all the information you need, make sure to save and close the file.

Preparing the Pi

At this point all the configuration is done. You can eject the SD card from your computer and insert it back into the Pi and power it up. Give the Pi a minute or so to do its initial boot as it will need to implement the changes we’ve configured.

You can also now hide file extensions in Windows Explorer if you wish to do so.

Connecting to your Pi

Now we can connect to the Raspberry Pi over SSH, to do this I shall be using PuTTY which is an SSH client available for Windows. You’ll also need iTunes installed for this next part, an odd requirement I know, or Bonjour Print Services — this will allow our SSH client to discover the Raspberry Pi on the network using the hostname.

As we don’t yet know the IP address of the Raspberry Pi, we shall be connecting to it using its default hostname of raspberrypi.local. If you wish to find out the IP address the best place to look will likely be your router’s administrator interface or the Fing app.

In PuTTY, enter raspberrypi.local into the host box. By default, the port should be set to 22 and the connection type to SSH, click Open to connect and accept the Security Alert if it pops up.

PuTTY Window
PuTTY is used to SSH into the Raspberry Pi

Once we’ve connected to the Raspberry Pi, we can log in using the default credentials of pi and raspberry and begin to use it however we want.

Wrapping Up

That’s how you can configure and use your Raspberry Pi headless, with only the power cable needing to be connected to it. I think it’s very cool how the Pi can be configured to do this and there is something novel about only needing to have a single power cable connected.

You May Also Like