Access Raspberry Pi Remotely From Anywhere Without Port Forwarding

Ganesh Velrajan
7 min readAug 7, 2023

In this blog, we’ll discuss how to securely connect to your Raspberry Pi or IoT device remotely from anywhere over the internet without port forwarding, allowing you to remotely manage your devices more effectively.

Raspberry Pi, a popular Single Board Computer (SBC), is a small, energy-efficient device that’s perfect for a variety of projects.

However, if not managed properly, these devices can become a liability and lead to customer churn, resulting in lost revenue.

Port forwarding via NAT router or Firewall is not a secure method to remotely access your Raspberry Pi from outside network over the internet. Port scanners and hackers could potentially access your Raspberry Pi or IoT device.

The biggest challenge for any IoT vendor is:
How to securely connect and manage Raspberry Pi remotely over the internet to login, debug, monitor, reboot, reconfigure and update it?

In this article, we’ll discuss how to configure and setup Raspberry Pi for remote access without setting up port forwarding:

We will be using SocketXP IoT Management and Remote Access Platform to remotely connect to Raspberry Pi over the internet without port forwarding.

You can use SocketXP to remotely connect to any Raspberry Pi behind NAT router and firewall from outside network such as the internet.

What is SocketXP

SocketXP is a cloud based secure remote access solution to access, manage and debug embedded Linux devices such as Raspberry Pi, Nvidia Jetson or an IoT device over the internet. SocketXP creates a secure SSL/TLS connection over the internet to your Raspberry Pi for secure remote access.

No configuration changes are required in your home or office router to make the SocketXP solution work. No public IP is required.

It simply works out of the box.

SocketXP creates SSL/TLS reverse proxy tunnels to securely connect to remote devices.

SocketXP does not use insecure methods such as port-forwarding techniques or Dynamic DNS(DDNS) to provide remote access to your Raspberry Pi.

SocketXP is an enterprise-grade IoT remote access and management platform trusted by thousands of customers around the world today for secure remote access to their Rasperry Pi over the internet from anywhere in the outside network.

Let’s dive in and get started.

1. Remotely connect to Raspberry Pi behind NAT router or firwall over the Internet using SSH

Secure Shell (SSH) is a network protocol that provides a secure means to connect to a raspberry terminal over an unsecured network such as the internet.

SSH follows a client server model — the SSH server runs on the raspberry pi and the SSH client runs on the user laptop or PC. SSH server listens on TCP port 22 by default.

OpenSSH provides an open source implementation of the SSH server and client software.

Note: Your Raspberry Pi comes installed with an SSH server software in it.

SSH client needs to know the IP address of the device in which the SSH server runs so that it can connect to it.

Because Raspberry Pi devices installed behind a NAT router and firewall cannot be access from the internet, we’ll use SocketXP Raspberry Pi Remote Access solution to remotely connect to the Raspberry Pi terminal using SSH over the internet from anywhere.

To learn more refer to: how to setup and configure your Raspberry Pi for remote SSH access over the internet

2. Connect to Raspberry Pi remotely over the Internet using VNC

Virtual Network Connection(VNC) is a protocol for safely accessing the Raspberry Pi Graphical User Interface(GUI) or desktop. VNC is typically used for remotely accessing the GUI of a Linux based platforms such as Raspberry Pi.

VNC follows a client server model — the VNC server runs on the raspberry pi and the VNC client runs on the user laptop or PC. VNC server listens on TCP port 5901 by default.

TightVNC is a open source based VNC software that can be installed on Raspberry Pi for remote desktop access.

Because Raspberry Pi devices installed behind a NAT router and firewall cannot be access from the internet, we’ll use SocketXP Raspberry Pi Remote Access solution to remotely connect to the Raspberry Pi GUI desktop using VNC over the internet from anywhere.

To learn more refer to: how to setup and configure your Raspberry Pi for remote VNC access over the internet

3. Connect to Raspberry Pi Remote Desktop(RDP) over the Internet using xrdp

Remote Desktop Protocol(RDP) is a proprietary protocol invented by Microsoft for accessing the Windows desktop of one Windows machine from another Windows machine in a local network.

RDP follows a client server model — the RDP server runs on the raspberry pi and the RDP client runs on the user laptop or PC. RDP server listens on TCP port 3389 by default.

Microsoft has opened up the RDP for third parties to implement the same. xrdp is a open source implementation of the Microsoft RDP. xrdp is typically used for remotely accessing the GUI desktop of a Linux based platforms such as Raspberry Pi.

Because Raspberry Pi devices installed behind a NAT router and firewall cannot be access from the internet, we’ll use SocketXP Raspberry Pi Remote Access solution to remotely connect to the Raspberry Pi GUI desktop using xrdp over the internet from anywhere.

To learn more refer to: how to setup and configure your Raspberry Pi for remote desktop access over the internet using xrdp

4. Remote Control Raspberry Pi Behind NAT router or Firewall using a Web App

Installing and running a IoT web application on your Raspberry Pi is one way to remotely connect and control your Raspberry Pi using a web client.

For example, you could write a simple python flask web server application to remotely access the files — images, videos from a web camera, configuration files, log files etc.

$ cat get_files.py 
from flask import Flask, send_from_directory

app = Flask(__name__) @app.route('/')

def send_report(path):
return send_from_directory('/', path)

if __name__ == '__main__':
app.run(host='127.0.0.1', port=3000, debug=True)

You can use a web browser to access this web server application running in your Raspberry Pi from a local network. Just point your browser to: http://localhost:3000

But, Raspberry Pi devices installed behind a NAT router and firewall cannot be access from the internet.

We’ll use SocketXP Raspberry Pi Remote Access solution to remotely connect to the python flask web server application over the internet from anywhere.

SocketXP creates a secure public web URL (HTTPS) for the local web app running in your Pi.

To learn more refer to: how to remote access Raspberry Pi web app over the internet

5. Send Remote Commands to Raspberry Pi over the Internet from Outside Network

Remote Command Execution — the ability to send one-off shell commands to your Raspberry Pi to quickly fetch crucial information or take some corrective action on your remote Raspberry Pi is immensely important.

It is cumbersome to always having to SSH login to your Raspberry Pi using your login and password to execute even a simple command or a program.

This becomes even more tedious if you have to execute the same script or command on a fleet of Raspberry Pi.

SocketXP Raspberry Pi Remote Access solution provides you the ability to remotely execute shell script, command or any python program on a single Raspberry Pi or on a fleet of Raspberry Pi over the internet.

To learn more refer to: how to setup and configure your Raspberry Pi for remote command execution over the internet

Conclusion:

In this article, we discused the five different options available to remotely access Raspberry Pi from anywhere without port forwarding using: SSH, VNC, RDP, Web App and Remote Command Execution.

We also discussed how SocketXP’s Raspberry Pi Remote Access solution offers a secure, powerful and convenient way to remotely manage and control your Raspberry Pi devices without enabling port forwarding.

With its user-friendly interface, advanced features, and unparalleled flexibility, this innovative solution is a must-have tool for Raspberry Pi enthusiasts.

Take advantage of this cutting-edge solution and unlock the full potential of your Raspberry Pi devices. Try SocketXP’s Raspberry Pi Remote Access solution and control your Raspberry Pi projects from anywhere.

--

--

Ganesh Velrajan

Ganesh Velrajan is the founder of Ampas Labs Inc. Learn more about our SSH Remote Access Solutions at https://www.socketxp.com and https://www.bastionxp.com