Skip to content

How to ssh into a Raspberry Pi

If you've ever worked with a Raspberry Pi, you'd know that having the ability to remotely access it can be incredibly useful. This is especially true if your Raspberry Pi is set up in a location that isn't easily accessible or if it's serving as a headless server without a monitor. In this guide, we'll walk you through how to SSH into a Raspberry Pi, allowing you to remote into your Raspberry Pi from anywhere with an internet connection.

Prerequisites

  • A Raspberry Pi with Raspbian OS (or any other compatible OS) installed.
  • An active internet connection on the Raspberry Pi.
  • Another device (like a PC) from which you'd want to remotely access the Raspberry Pi.
  • Familiarity with basic command line instructions.

Step 1: Enable SSH on the Raspberry Pi

Before you can SSH into your Raspberry Pi, SSH needs to be enabled.

  1. Using Raspi-config:

    • Open a terminal on your Raspberry Pi.
    • Type sudo raspi-config and press Enter.
    • Navigate to Interfacing Options, then select SSH, and choose Enable.
    • Exit the configuration tool.
  2. Using the GUI:

    • If you're using the Raspbian desktop, click on the Raspberry Pi icon > Preferences > Raspberry Pi Configuration.
    • Navigate to the "Interfaces" tab.
    • Set "SSH" to "Enabled".

Step 2: Find the IP Address of the Raspberry Pi

To SSH into the Raspberry Pi, you'll need its IP address.

On the Raspberry Pi terminal, type:

hostname -I

This will display the IP address of your Raspberry Pi. Note this down.

Step 3: SSH from Your PC

Now that you have SSH enabled and have the IP address, it's time to remote into the Raspberry Pi from your PC.

For Linux or MacOS:

  1. Open the terminal.
  2. Type:
ssh pi@YOUR_RASPBERRY_PI_IP_ADDRESS

Replace YOUR_RASPBERRY_PI_IP_ADDRESS with the IP address you noted in the previous step.

For Windows

Windows doesn't come with a built-in SSH client, but you can use a third-party tool like PuTTY.

  1. Download and install PuTTY.
  2. Open PuTTY.
  3. In the “Host Name (or IP address)” field, type in the IP address of the Raspberry Pi.
  4. Make sure the port is set to 22 (the default for SSH).
  5. Click “Open”.

Step 4: Logging In

By default, the Raspberry Pi has a user named pi. When prompted for a password, use the default password raspberry. It's recommended to change this password after your first login using the passwd command for security reasons.

Once logged in, you're now remotely connected to your Raspberry Pi via SSH! You can run any command as if you're sitting right in front of it.

Conclusion:

Learning how to SSH to a Raspberry Pi is a fundamental skill that greatly enhances the usability and accessibility of your device. Now that you can remote into your Raspberry Pi, managing, configuring, and troubleshooting become much more convenient.

Remember, it's essential to keep your device secure. Always ensure your software is up-to-date and consider changing default passwords and implementing key-based authentication for added security.

There are a few drawbacks with the explained method. The main being that the ssh port 22 needs to be accessible from the outside. This opens up a lot of security concerns and we strongly advise against having an open port 22 over the internet. In order to get around this you could use qbee.io which is very easy to use and builds up a VPN reverse tunnel from any device out there. Then you can access the device through qbee in a very safe and convenient way. Even through your web browser. For more information on how to remote into a Raspberry Pi with security follow the link.