Connecting to Your Raspberry Pi from Anywhere with SSH

A step-by-step guide on how to set up remote login on your Raspberry Pi for convenient and secure access from anywhere. …


Updated August 11, 2023

Need help with your Raspberry Pi?
Contact Me!

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


A step-by-step guide on how to set up remote login on your Raspberry Pi for convenient and secure access from anywhere.

Remote login to Raspberry Pi using SSH (Secure Shell) is a powerful feature that allows you to control your Raspberry Pi from any device with an internet connection. With this guide, you’ll learn how to set up remote login on your Raspberry Pi and connect securely from another computer or device.

Prerequisites

Before we begin, make sure you have the following:

  1. A Raspberry Pi running the latest version of Raspbian or any other Linux-based operating system.
  2. An internet connection for your Raspberry Pi and the computer you’ll be using to remotely access it.
  3. A static IP address (if not, you can reserve a dynamic DNS domain name).

Setting up Remote Login on Your Raspberry Pi

To enable remote login on your Raspberry Pi, follow these steps:

  1. Open the terminal on your Raspberry Pi and update the system by typing:
sudo apt-get update && sudo apt-get upgrade
  1. Install SSH server if it’s not already installed:
sudo apt-get install openssh-server
  1. Start the SSH service:
sudo systemctl start ssh
  1. Enable the SSH service to start automatically on boot:
sudo systemctl enable ssh
  1. Find your Raspberry Pi’s local IP address by running:
hostname -I
  1. Note down your Raspberry Pi’s local IP address (e.g., 192.168.1.10). You will use this to connect remotely.

Setting up Port Forwarding on Your Router

To allow remote access from the internet, you need to forward a port on your router to your Raspberry Pi’s local IP address. Here’s how:

  1. Log in to your router’s admin panel by entering its IP address (e.g., 192.168.1.1) in a web browser. The default username and password are usually admin/admin or root/root.
  2. Navigate to the port forwarding settings page. This is typically found under “Advanced Settings” or “Applications & Gaming.”
  3. Add a new port forwarding rule with the following details:
  • Name: Raspberry Pi SSH
  • Protocol: TCP
  • Public Port: Choose any unused port (e.g., 22222)
  • Private Port: 22 (the default SSH port)
  • IP Address: Your Raspberry Pi’s local IP address (from step 5)
  1. Save the settings and exit the router admin panel.

Connecting to Your Raspberry Pi Remotely

Now that your Raspberry Pi is set up for remote login, you can connect from another computer or device using an SSH client. Here’s how:

  1. Download an SSH client for your operating system if you haven’t already (e.g., PuTTY for Windows, Terminal for macOS/Linux).
  2. Open the SSH client and enter the following details:
  • Host Name: Your router’s public IP address (check online services like whatismyipaddress.com to find it)
  • Port: The port you forwarded in step 3 (e.g., 22222)
  • Username: pi (or the username you set up on your Raspberry Pi)
  • Password: The password for the selected user
  1. Click “Connect” or enter the connection command in your terminal (for macOS/Linux):
ssh -p 22222 pi@your_router_ip_address

Replace your_router_ip_address with your actual router’s public IP address.

That’s it! You should now be connected to your Raspberry Pi remotely. If you have any issues, double-check the port forwarding settings and ensure that the SSH server is running on your Raspberry Pi.

Conclusion

With remote login set up, you can securely access your Raspberry Pi from anywhere with an internet connection. This is a powerful tool for monitoring your Pi’s status, managing files, or even controlling it remotely via command line. Enjoy the convenience and security of remote login on your Raspberry Pi!