Setting up SSH on a Raspberry Pi allows one or more users to enable ssh to log in to the system remotely for administration or other tasks via a separate command line terminal. SSH is a client-server protocol that provides secure, encrypted connections over a network connection (could be a local network or over the internet). This allows users to SSH into the Raspberry Pi from another Linux system or other SSH client.
In this tutorial, we will look at how to enable SSH on a Raspberry Pi. There are two main ways to get this done, either by interacting directly with the Raspberry Pi and configuring SSH, or by configuring the installation settings via the Raspberry Pi imager tool, which allows us to enable SSH before actually booting into Raspberry Pi OS for the first time. Since both options cover different scenarios, we will look at both methods below.
Software Requirements and Linux Command Line Conventions
Category
Requirements, Conventions or Software Version Used
System
Raspberry Pi
Software
OpenSSH
Other
Privileged access to your Linux system as root or via the sudo command.
Conventions
# โ requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command $ โ requires given linux commands to be executed as a regular non-privileged user
Enabling SSH: Which Method?
There are two scenarios that you may find yourself in:
Scenario 1) You just bought a Raspberry Pi, and need to configure it so that you can SSH into the device once it is up and running. In this case, you will need to enable and configure SSH from the Raspberry Pi imager tool, so that you can start using SSH to manage your Raspberry Pi from the very first time it boots into the operating system.
Scenario 2) The operating system has already been installed on your Raspberry Pi, and you have been using it as normal. Now, you want to enable SSH so that you can continue to log in and administer the device from over the network. In this case, we can just install, enable, and configure SSH from the command line on the Raspberry Pi.
Depending on which situation you are in, will determine the set of instructions you should follow below.
Enable SSH via Raspberry Pi Imaging Tool
For this section, it is assumed that you do not yet have the Raspberry Pi OS installed on your device, and you wish to configure the SSH settings so that you are able to log in to the Raspberry Pi via SSH when it is booted up for the first time.
You can download the Raspberry Pi imaging tool from by navigating to the Raspberry Piโs website and going to the Raspberry Pi OS download page. On this page, we need to download the Raspberry Pi imaging tool. Be sure to select the one that corresponds to your current operating system โ either Linux, Windows, or MacOS.
๐ Downloading the Raspberry Pi OS imaging tool Downloading the Raspberry Pi OS imaging tool
After opening the Raspberry Pi imager tool and selecting the Raspberry Pi OS for installation, you will see a cog wheel icon appear on the tool. This allows us to configure essential settings such as SSH for our installation. During installation, we will not go through traditional prompts as is usual on Linux installs, but rather we preconfigure all the settings in the imaging tool. ๐ Click the cog wheel icon to open the settings menu Click the cog wheel icon to open the settings menu
Remember to also configure a username and password when enabling SSH.
Enable SSH on Raspberry Pi
This next method assumes that you already have your Raspberry Pi up and running, have an established connection to it (such as physically via keyboard and monitor), and wish to now enable SSH on the device.
The easiest way to enable SSH on an existing Raspberry Pi OS installation is via the raspi-config utility. Get started by opening a command line terminal and executing the following command:
Then, select the option to enable SSH. There will be one more prompt to make sure that you really want to enable it.
๐ Prompt in raspi-config to finish enabling SSH Prompt in raspi-config to finish enabling SSH
Closing Thoughts
In this tutorial, we saw how to enable SSH on a Raspberry Pi. The SSH protocol allows users to log into and administer their Raspberry Pi from another computer on the network or from over the internet. As a matter of fact, users can configure SSH before ever booting up their Raspberry Pi, ensuring that it is ready to use SSH from the moment it first boots up.