Connecting to Your Remote Raspberry Pi Through SSH

Learn how to connect to your Raspberry Pi from a different network and control it remotely using the Secure Shell (SSH) protocol. …


Updated October 17, 2023

Need help with your Raspberry Pi?
Contact Me!

Do you love silly Raspberry Pi Projects?
Check out my this YouTube Channel!


Learn how to connect to your Raspberry Pi from a different network and control it remotely using the Secure Shell (SSH) protocol.

SSH, or Secure Shell, is an essential tool for controlling remote devices like Raspberry Pis over a network. In this article, we will explore how to SSH into your Raspberry Pi from different networks and what you need to do to set it up.

Setting Up SSH on Your Raspberry Pi

Before you can connect to your Raspberry Pi from a remote location, you need to ensure that the SSH server is running on the device. By default, the Raspberry Pi OS comes with SSH enabled, but if you are using a custom image or have disabled it, follow these steps to enable it:

  1. Open the terminal on your Raspberry Pi and enter sudo raspi-config to open the configuration tool.
  2. Navigate to Interfacing Options > SSH and select “Enable” or “Yes”.
  3. Exit the configuration tool, and reboot your device with sudo reboot.

Finding Your Raspberry Pi’s IP Address

To connect to your Raspberry Pi over a network, you need to know its IP address. Here are two ways to find it:

  1. Using the command line on the Raspberry Pi itself: Run hostname -I to display the device’s local and external IP addresses. Copy the external IP address (e.g., 192.168.1.10).

  2. Using a router or DHCP server: Log in to your home network’s router or DHCP server and find your Raspberry Pi’s assigned IP address under the list of connected devices.

Connecting from the Same Network

If your local device is on the same network as the Raspberry Pi, you can connect directly using its local IP address:

  1. Open a terminal or command prompt on your local device.
  2. Type ssh pi@<raspberry_pi_local_ip> and press Enter (e.g., ssh pi@192.168.1.10).
  3. If this is the first time connecting, you may see a warning about the authenticity of the host. Type “yes” to continue.
  4. Enter your Raspberry Pi’s password when prompted (default: raspberry).

You are now connected to your Raspberry Pi and can run commands as if you were sitting in front of it. To exit, type exit or press Ctrl+D.

Connecting from a Different Network

If you are not on the same network as your Raspberry Pi, you will need to use its external IP address and port forwarding:

  1. Set up port forwarding on your router to forward incoming SSH connections (typically port 22) to your Raspberry Pi’s internal IP address. Consult your router’s documentation for instructions.

  2. Find your Raspberry Pi’s external IP address by using a service like WhatIsMyIP.

  3. Open a terminal or command prompt on your local device.

  4. Type ssh pi@<raspberry_pi_external_ip> and press Enter (e.g., ssh pi@203.0.113.5).

  5. If this is the first time connecting, you may see a warning about the authenticity of the host. Type “yes” to continue.

  6. Enter your Raspberry Pi’s password when prompted (default: raspberry).

You are now connected to your Raspberry Pi from a different network and can run commands as if you were sitting in front of it. To exit, type exit or press Ctrl+D.

Remember that leaving an SSH server open to the internet can expose your device to security risks. Be sure to enable a strong password and use a VPN or other security measures when connecting from untrusted networks.