DEV Community

Cover image for How to Set Up a Raspberry Pi Tunnel for Remote Access
Lightning Developer
Lightning Developer

Posted on

How to Set Up a Raspberry Pi Tunnel for Remote Access

Securely connect to your Pi from anywhere—without touching your router.

If you’ve ever tried to connect to your Raspberry Pi while away from home, you know the struggle. Maybe you wanted to check in on a home automation dashboard or push code to a project you left running. But unless you’ve spent time digging through router settings and dealing with port forwarding, you probably hit a wall.

Most home networks today are tucked behind NATs. Many ISPs use CG-NAT on top of that, making your Raspberry Pi practically invisible to the internet. Even if you do manage to forward a port, you might run into firewalls, dynamic IPs, or security concerns. It’s a lot of work just to send a few commands from your laptop at work.

This is where tunneling comes in. Instead of exposing ports through the router, a tunnel creates an outbound connection from the Pi to a public endpoint, bypassing all the common network hurdles. One popular approach is using an SSH-based tunnel with a service like Pinggy, which gives you a public address that routes traffic back to your Pi securely.

What Is a Raspberry Pi Tunnel?

Think of a tunnel as a secure link that punches through your local network to make your Raspberry Pi accessible from the internet. You don’t have to expose your entire system—just the services or ports you want.

There are generally two types of tunnels you’ll find useful:

  • HTTP tunnels let you expose web apps (like dashboards, file servers, or cameras) through a temporary or persistent public URL.
  • SSH tunnels give you command-line access to your Pi as if you were on the same local network—perfect for updates, code pushes, or quick fixes.

Why Port Forwarding Usually Fails

Setting up port forwarding used to be the go-to way to access devices remotely. But it’s increasingly unreliable today, mostly because of:

  • Carrier-Grade NAT (CG-NAT) from ISPs
  • Routers that make forwarding difficult or inconsistent
  • Frequent changes in public IP addresses
  • Security risks from exposing services directly
  • Firewalls on public or corporate networks

These problems aren’t just annoying; they can make remote access impossible unless you try a different approach.

Step 1: Enable SSH on the Raspberry Pi

Before you can tunnel into your Pi, you need to make sure SSH is enabled.

To do that, open a terminal on the Pi or connect via a local keyboard and monitor, then run:

sudo systemctl enable ssh sudo systemctl start ssh 
Enter fullscreen mode Exit fullscreen mode

You can confirm it’s running with:

sudo systemctl status ssh 
Enter fullscreen mode Exit fullscreen mode

For added security, consider setting up SSH key authentication and changing the default port, especially if you’ll be accessing it from the internet.

Step 2: Create an HTTP Tunnel

If you’re hosting a local web app-like a home automation dashboard, a self-hosted cloud, or a simple server, you can make it publicly accessible through a tunnel.

Let’s say you’re running a basic web server on port 8080:

python3 -m http.server 8080 
Enter fullscreen mode Exit fullscreen mode

To expose this via a tunnel, you can run:

ssh -p 443 -R0:localhost:8080 qr@free.pinggy.io 
Enter fullscreen mode Exit fullscreen mode

Once connected, you’ll get a unique URL that routes to your Pi. That link (e.g., https://randomsubdomain.pinggy.link) will open your web interface, even if your Pi is behind a NAT or firewall.

pinggy_url

This works for more complex apps too; anything running on HTTP or HTTPS.

Step 3: Set Up an SSH Tunnel for Terminal Access

Sometimes, what you need is terminal access, not a web interface. Maybe you're updating packages, checking logs, or deploying code.

To set up an SSH tunnel from your Pi, run:

ssh -p 443 -R0:localhost:22 tcp@free.pinggy.io 
Enter fullscreen mode Exit fullscreen mode

You’ll receive a connection string like:

tcp://randomhost.pinggy.link:40527 
Enter fullscreen mode Exit fullscreen mode

From another machine, you can connect back to your Pi like this:

ssh pi@randomhost.pinggy.link -p 40527 
Enter fullscreen mode Exit fullscreen mode

url

This gives you full remote access to the Pi’s shell—no VPN, no dynamic DNS, no router reconfiguration.

Use Cases for Raspberry Pi Tunnels

Once your Pi is reachable from anywhere, your possibilities expand. Here are just a few ideas:

  • Monitor security cameras from your phone
  • Access a smart home dashboard while traveling
  • Update or restart services from a coffee shop
  • Run a web app or bot that needs outside connectivity
  • Debug Raspberry Pi projects from a remote terminal

For developers, this also means easier collaboration—just share a URL to your local server without deploying it live.

Security Tips

Tunneling makes access easier, but it still needs to be secure. Here are some quick tips:

  • Use key-based SSH authentication
  • Disable root login via SSH
  • Don’t expose services you don’t need
  • Use a trusted tunneling tool that encrypts traffic
  • Regularly audit what ports and services are being tunneled

Final Thoughts

Tunneling gives you full control over your Raspberry Pi, without the usual headaches of network configuration. With one command, you can punch through NAT, skip port forwarding, and reach your Pi from anywhere.

Tools like Pinggy make this even simpler by providing public URLs out of the box, with support for both HTTP and SSH. It’s a lightweight, secure, and fast way to bring your Pi online, without punching holes in your firewall.

Whether you’re running a smart home, building a side project, or just want to stay connected to your Raspberry Pi wherever you go, setting up a tunnel is one of the easiest ways to get there.

References

  1. How to Set Up Raspberry Pi Tunnel for Remote Access
  2. Access raspberry pi remotely to control iot devices
  3. Pinggy's Documentation

Top comments (0)