Securely Access Your Raspberry Pi Remotely with Just a Few Clicks

Learn how to access your Raspberry Pi remotely using SSH, enabling you to control and manage it from anywhere. This guide will show you how to set up port forwarding on your router and securely connec …


Updated October 26, 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 access your Raspberry Pi remotely using SSH, enabling you to control and manage it from anywhere. This guide will show you how to set up port forwarding on your router and securely connect via an SSH client.

Prerequisites:

  • A Raspberry Pi with Raspbian OS (or another Linux distribution) installed and configured
  • A static IP address for your Raspberry Pi (recommended but not required)
  • A router or modem that supports port forwarding
  • An SSH client on your local machine (e.g., PuTTY for Windows, Terminal for macOS/Linux)

Step 1: Enable SSH on Your Raspberry Pi

Open the terminal on your Raspberry Pi and type the following command to start the SSH server:

sudo systemctl enable ssh

Now, restart the Pi:

sudo reboot

Step 2: Set Up Port Forwarding on Your Router

To allow incoming connections to your Raspberry Pi through your router, you’ll need to set up port forwarding. This will direct incoming traffic on a specific port (usually port 22) to your Pi’s IP address. Here’s how:

  1. Log in to your router’s administration interface by typing its IP address into a web browser. The default username and password are often “admin” and “admin”, but this may vary depending on your model.
  2. Navigate to the port forwarding settings page. This is usually located under “Advanced Settings” or “Applications & Gaming”.
  3. Add a new port forwarding rule with the following settings:
  • External (WAN) port: 22
  • Internal (LAN) IP address: Your Raspberry Pi’s local IP address (e.g., 192.168.1.100)
  • Internal (LAN) port: 22
  1. Save the changes and exit the router administration interface.

Step 3: Connect to Your Raspberry Pi Using an SSH Client

Now that your Pi is ready to accept remote connections, it’s time to connect using an SSH client. Here are some examples for Windows, macOS, and Linux:

Windows:

  1. Download PuTTY from here.
  2. Open PuTTY and enter your Pi’s external IP address (the one provided by your internet service provider) in the “Host Name (or IP address)” field.
  3. Click “Open” to connect. You may be prompted to accept the server’s key fingerprint.
  4. Enter your Raspberry Pi username and password when prompted.

macOS/Linux:

  1. Open a terminal window.
  2. Type the following command, replacing your_username with your Pi’s username, and your_pi_ip with its external IP address:
ssh your_username@your_pi_ip
  1. Enter your Raspberry Pi password when prompted.

That’s it! You should now be connected to your Raspberry Pi via SSH from anywhere in the world. Enjoy remotely managing and controlling your Pi from the comfort of your couch or while on the go.