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.
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 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.
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.
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.
You'll now want to launch Notepad and open the file.
Change the file format from Text Document to All Files so we can bring up the configuration
file.
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 into your file.
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.
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.
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.
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.
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.
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.
That’s been it for this video, if you liked it please consider subscribing.
I will leave a link in the description to an article that will have all the links and
code you’ll need.
Thanks for watching and I will see you in the next one.