Remote Desktop for Raspberry Pi and other IoT devices
Updated on Aug 25, 2024 · 3 mins read
You remotely access your Raspberry Pi desktop from anywhere using Remote Desktop Protocol (RDP). Even if your Pi is outside your local network, you can access it easily over the internet using Pinggy.
Summary
-
Step 1. Run these commands on your Raspberry Pi:
sudo apt update sudo apt install xrdp sudo systemctl start xrdp
-
Step 2. Run this command to get a public URL to your Raspberry Pi:
ssh -p 443 -R0:localhost:3389 tcp@a.pinggy.io
You will get a URL and port in the output such as:
tcp://tljocjkijs.a.pinggy.link:40527 -
Step 3. Open Remote Desktop Connection application on your Windows / Microsoft Remote Desktop on Mac. Enter the URL:Port to connect.
Example:tljocjkijs.a.pinggy.link:40527
-
Sign in to https://dashboard.pinggy.io to get your ongoing tunnel URLs from the dashboard.
The Remote Desktop Protocol (RDP) enables users to connect to and control Raspberry Pi or similar devices via a network connection. However, this is only possible if the device is on the local network (LAN) or has a public IP address. Often, Raspberry Pi and similar devices are located behind NAT or CGNAT, as well as firewalls, lacking a public IP address. In such situations, Pinggy.io can be employed to access your device over the internet, providing a public address without requiring software installation. Through the Pinggy TCP tunnel, you can access your RDP-enabled device over the internet, circumventing NAT and firewalls.
The above video shows you the steps. Below is an outline of how to remotely access your Raspberry Pi like device from anywhere over the internet.
Step 1. Install RDP server
On your device install an RDP server such as xrdp. On your Raspberry Pi, you can install xrdp using the following commands in the terminal:
sudo apt update
sudo apt install xrdp
sudo systemctl start xrdp
Step 2. Start Pinggy TCP tunnel
To get a public URL to access your Raspberry Pi over the internet bypassing NAT and firewall, you need to start a Pinggy tunnel. Just copy and paste the following command to start a tunnel.
ssh -p 443 -R0:localhost:3389 tcp@a.pinggy.io
Step 3. Obtain the Public URL
After running the tunneling command, you will receive a public URL in the following format: tcp://tljocjkijs.a.pinggy.link:40527
Make note of this URL (tljocjkijs.a.pinggy.link) and port (40527) as they will be used to establish an RDP connection to your Raspberry Pi or other IoT device.
To avoid copying the URL, you can sign in to https://dashboard.pinggy.io to get an access token. When you start a tunnel using your access token, you can find ongoing tunnel URLs from the dashboard.
Step 4. Connect to remote desktop
Open Remote Desktop Connection application on your Windows / Microsoft Remote Desktop on Mac. Enter the URL:Port to connect.
Tips
Pinggy free tunnels expire after 60 minutes, and the URLs change after reconnection. To avoid this, sign in to https://dashboard.pinggy.io and get an access token. Then run the tunnel in auto-reconnection mode.
while true; do
ssh -p 443 -o ServerAliveInterval=30 -R0:localhost:3389 tcp@a.pinggy.io;
sleep 10; done
From the Pinggy dashboard you will be able to see the list of your active tunnels.