banner

News

Aug 29, 2023

How to SSH Into a Raspberry Pi for Remote Access

Access and control your Raspberry Pi remotely via SSH from any computer or even an Android phone.

When running a project on a headless Raspberry Pi, it may not always be convenient to plug it into a monitor when you want to change something, but you don't need to. You can access and control the Raspberry Pi remotely via SSH (Secure SHell) from another computer or even a smartphone on the same network. This guide will first show you how to enable SSH, then how to SSH into Raspberry Pi from another device.

By default, for security reasons, SSH is disabled in the standard Raspberry Pi OS. So, to be able to SSH to Pi, you will first need to enable it. If you are installing Raspberry Pi OS from scratch onto a microSD card, you can use the Advanced Settings in Raspberry Pi Imager tool (click the cog icon) to enable SSH and set a username and password. While you’re at it, add your wireless network details so that the Raspberry Pi will automatically connect to it. Click Save to keep the settings, then write the OS to your microSD card as usual.

Alternatively, you can enable SSH from within an existing installation of Raspberry Pi OS. With your Raspberry Pi connected to a monitor, open the raspberry icon menu on the desktop and select Preferences > Raspberry Pi Configuration. Then click the Interfaces tab and click the Enabled radio button for SSH.

If using Raspberry Pi OS Lite (without the desktop GUI), you can enable SSH via the raspi-config utility. Enter the command:

Then navigate to Interfacing Options > SSH and select <Yes> at the prompt, "Would you like the SSH server to be enabled?" Press Enter to confirm, then select Finish to exit raspi-config.

WIth SSH enabled and your Raspberry Pi connected to your network, you are ready to connect to Raspberry Pi via SSH from another device. You will need to know either your Raspberry Pi's hostname (raspberrypi.local is the default, but you can set it in Raspberry Pi Imager's Advanced Settings) or its IP address to log in.

You can find the Raspberry Pi's IP address by visiting your router's homepage to see a list of connected devices. Alternatively, to find the IP address from the Raspberry Pi (connected to a monitor), enter this Terminal command:

So that it never changes, you may also want to set a static IP address on Raspberry Pi. Alternatively, you may be able to reserve an IP address for the Raspberry Pi in your router's settings.

On a Windows 10 or 11 PC, you can use the PowerShell to SSH into Raspberry Pi. Press Ctrl + Shift + P to open the PowerShell, then enter either of these commands:

or

Replace [username] and [hostname] or [IP address] with your own Pi's details. For example, ssh [email protected] or ssh [email protected].

Alternatively, you can use the PuTTY utility, which is a more sophisticated tool and will work on any Windows PC. In the PuTTY dialog, select SSH as the connection type, enter the Raspberry Pi's IP address or hostname in the Host Name (or IP address) box, then click Open. You can also click Save to save the connection details in PuTTY.

On a Mac, open the Terminal utility (in Applications > Utilities), then enter either of the following commands to connect to Raspberry Pi via SSH:

or

Replace [username] and [hostname] or [IP address] with your own Pi's details. For example, ssh [email protected] or ssh [email protected].

On a Linux PC (or even another Raspberry Pi), open a Terminal window by pressing Ctrl + Alt + T, then enter either of the following commands to connect to Raspberry Pi via SSH:

or

Replace [username] and [hostname] or [IP address] with your own Pi's details. For example, ssh [email protected] or ssh [email protected].

There are several SSH remote access apps available in the Play Store, such as the free ConnectBot. To connect to your Raspberry Pi with it, click the + (plus) symbol and enter the login details, such as [email protected] or ssh [email protected]. You can also give it a nickname if you want. Click the + (plus) symbol to save the connection, then click on it from the list to connect to Raspberry Pi. Enter your password and you're in.

You now know how to enable SSH on Raspberry Pi, find its IP address, and then SSH into it from another device to control it remotely using standard Linux terminal commands. This is a very useful skill when you are using a Raspberry Pi headless, without a monitor or keyboard connected.

Phil is the Section Editor for DIY projects at MUO and a freelance writer and editor with 20+ years of experience. He has edited numerous official Raspberry Pi books and is a regular contributor to The MagPi magazine.

MAKEUSEOF VIDEO OF THE DAY SCROLL TO CONTINUE WITH CONTENT Save Preferences Raspberry Pi Configuration Interfaces Enabled SSH Interfacing Options SSH <Yes> Enter Finish raspberrypi.local Ctrl + Shift + P [username] [hostname] [IP address] ssh [email protected] ssh [email protected] SSH Host Name (or IP address) Open Save Applications Utilities [username] [hostname] [IP address] ssh [email protected] ssh [email protected] Ctrl + Alt + T [username] [hostname] [IP address] ssh [email protected] ssh [email protected] + [email protected] ssh [email protected]
SHARE