How to Connect a Raspberry Pi to Wi-fi Via SSH

This site contains affiliate links to products. We may receive a commission for purchases made through these links.

The Raspberry Pi computer system remains one of the best of its class when looking at budget and flexibility in areas of use. It is a single-board computer, which you can easily distinguish from other computers due to its naked build. 

Some of the functions you can use this computer include programming in languages like Python and Scratch and small-scale projects, mostly the do-it-yourself type. When you get this computer, setting it up is a significant part of its operation.

You need to connect it to hardware such as the keyboard, mouse, monitor, and many more. To improve its functionality, you need to connect it to the internet.

Focusing on the significance of the internet, one of the skills you should have is how to connect Raspberry Pi to Wi-Fi via SSH.

Let us have a brief look at the Wi-Fi’s role before looking at how to connect it.

AdobeStock 392673643 1

The Role of the Internet

When talking about the internet, the first thing that hits our mind is browsing the web. While that is one of the purposes of connecting the Raspberry Pi via Wi-Fi, there are several other reasons.

One of them is for upgrades and updates of the system and the several programs it supports. The programs need to be in the best shape and up to date for you to get the best out of them. With an internet connection, this is possible as you can turn on automatic updates and upgrades, saving you from breaking a sweat due to manual searching.

There are also resources that you get from various sites, such as plugins that will help in the running of your system. The plugins play a significant role when you are running online applications or programs.

On online applications, having an internet connection helps you gain access. Online programs are vital, especially if you do not have enough storage space on your device or if temporarily running them. 

Looking at all the resources, you can get from the internet, you understand that it is vital for your computer. There are two common ways to connect to the internet, where you can use an ethernet cable or a Wi-Fi dongle if you have the newer Raspberry Pi models.

A Wi-Fi dongle is more adaptable as you have unrestricted movement and a more extended reach. Now let us see how to connect Raspberry Pi to Wi-Fi via SSH.

Step 1: Have the Right Resources

Before beginning the connection, you need to have the right resources on your computer. These resources are sufficient storage, which you can support by providing external storage media like a memory card or flash drive.

The operating system should also be up to date, something you can ensure by checking on the system’s release file’s content. Run this prompt to confirm the status of the Raspbian operating system.

cat /etc/os-release

If it is an outdated version, you can use the following commands on the terminals for an update and upgrade, respectively.

sudo apt-get update

sudo apt-get upgrade

You have to get the upgrade to support the Raspbian distribution and make it compatible with other resources.

Step 2: Enable SSH and Wi-Fi

The second step requires you to enable the secure shell (SSH). The newer release Raspberry OS has the SSH disabled by default; hence, you need to enable it manually from your desktop.

Start by launching the Raspberry Pi configuration and go to the preferences menu. From the menu, click on the interfaces tab, and next to SSH, select enable and finalize by clicking ok.

Optionally, you can use the terminal, where you key in a command prompt as follows, to enable the secure shell.

sudo raspi-config, then select interfacing options and navigate to SSH. Click on yes, then select ok and click on finish to complete the process.

Step 3: Creating a File on Your Storage Media

Once you enable the secure shell, you now have to create a file on your storage media; in this case, let us assume it is a memory card. Launch the memory card menu on your computer and create an SSH file, and it should not have a prefix.

Then go to the memory card menu again and click on folder boot and open this file; wpa_supplicant.conf. Then paste a command prompt providing the network details and pay attention to the service set identifier, country, and the pre-shared key.

Step 4: Getting Wireless LAN Network Details

You now have to scan for the wireless LAN networks around you and choose the one you want to join. You can use a command prompt to get the available networks around, where you key in the following on the terminal line: sudo iwlist wlan0 scan

When you run the prompt, you will see the network’s details like the network name and authentication. Select the network of your choice and provide a password to connect.

What to Note When Setting Up A WLAN Connection

Pay attention to the following when connecting to a Wi-Fi connection.

  • Have sufficient storage on your device for applications to run and to connect well to the internet. You can use secondary storage media to expand your storage. To check if you have sufficient space on your memory card or any other media, run this prompt; df –h
  • You should also have an updated operating system to perform the connection. If it is not up to date, you may encounter compatibility issues that will drag you.
  • For unsecured networks, you will need to have the correct key management entry for access.
  • If you are looking for hidden networks, the scan_ssid prompt can help with location.

Final Word

Internet connection is essential to a computer system and adds several functionality levels, such as browsing and automatic updates and upgrades. We have come across the steps on how to connect Raspberry Pi to Wi-Fi via SSH, to grant you access to several resources on the web. 

Follow the steps and make your Raspberry Pi a robust system, where you should also ensure it has sufficient storage space.

About The Author