Raspberry Pi is a versatile single-board computer used by hobbyists and professionals alike for a wide range of projects. Its small form factor and low cost make it suitable for learning programming, building electronics projects, automating your home, and much more.
However, connecting Raspberry Pi remotely is essential for many projects and use cases. Having a keyboard, mouse, and monitor connected to the Pi at all times may not be feasible or practical. Fortunately, there are several easy methods to access and control the Pi over a network or the internet. This allows you to work on projects and manage the Pi without needing physical access.
In this comprehensive guide, we will explore the most common and easy methods to connect to your Raspberry Pi remotely over a network or the internet:
SSH gives you remote terminal access to the command line of Raspberry Pi
VNC and XRDP allow access to the full GUI desktop of your Raspberry Pi
VPN helps connect Raspberry Pi securely from anywhere by tunneling into your home network
Third-party tools offer user-friendly options for quick access
We will cover how to set up and use each method on both the Pi server and client side. You’ll learn the steps to get started along with the pros and cons of each approach.
By the end, you’ll be able to easily configure remote access to your Raspberry Pi. This opens up many possibilities like running headless automation, remotely monitoring projects, or controlling your Pi from mobile devices.
If you are using Raspberry Pi for the first time, please read this first: How to set up a Raspberry Pi for the first time? This will give you complete information about setting up your Raspberry Pi.
Before directly going to learn how to connect Raspberry Pi remotely. It is much needed to configure a static IP address to the Pi. There are two ways to configure a static IP address to the Pi.
I believe you are aware of the DHCP service. This service is developed to assign IP addresses to the devices connected to the network. Ideally, this service is managed by your home router. When you connect your Pi to your router either over Ethernet or WiFi, your router assigns an IP address to your Pi. Bear in mind; that this address is dynamic. The router assigns a new address once after the lease period elapsed. This nature of DHCP may force you to set up a remote connection each time your Pi gets a new address. And, you may lose control over your Pi if you are outdoors. This may create a hassle for you. To avoid this mess, it is better to configure Pi with a static IP address to make your settings more stable.
To assign a static lease to Pi, note down the mac address of the network interface of the Pi using ‘ifconfig’ command. And make an entry on the router and map the mac address of Pi to an IP address. This configuration allows the router to never expire the lease and keep the IP static. We can’t cover how to make this change on the router as the steps may differ on each router model. Please go through your router’s user manual to set the configurations on your router.
Note: Your Raspberry Pi may have multiple network interfaces. Ensure to choose the correct interface. In this example, our Pi has three interfaces: eth0, lo, and wlan0. eth0 is your wired interface. If you connected your Raspberry Pi over wired LAN, you should consider eth interface. lo is the lookback interface. and the last one wlan0 is the wireless network interface. If you connected your Raspberry Pi to your Wi-Fi network, you should consider wlan interface.
Output of ifconfig command
This option is quite easy too. You may need to manually track to avoid accidentally assigning the same IP address to more than one device on the network. Follow these steps to configure a static IP address on the Raspberry Pi.
Hit a WiFi symbol or LAN symbol and select network settings on the drop-down menu.
Network settings in Raspberry Pi
2. Select the correct Interface. Enter the IP address, Router, and DNS server’s IP address and hit apply and close.
select the network interface in Raspberry Pi
3. Reboot the Pi So That All Changes Can Take Effect
All right, now we are set to go. There are several ways to connect Pi remotely. We are going to tell you the five most commonly used methods in this article.
Before we see the ways to access Raspberry Pi remotely, let’s see some of the advantages to connect Raspberry Pi from remote. There are several compelling reasons you may want to connect to your Pi remotely:
Convenience – You can work on your Pi projects and manage the system from any device like a laptop, tablet, or phone. No need to hook up peripherals each time.
Accessibility – Remotely log in to your Pi and tinker with projects whether you’re at home, work, or anywhere else with internet. No physical access required.
Collaboration – For team projects, remote access allows others to conveniently log in and collaborate from their own location.
Monitoring – Check on the status of long-running tasks like 3D prints. Streaming webcam video is also possible over a remote desktop.
Control Automation – Remotely turn on/off connected devices like lights and motors based on sensor data and triggers.
Security – Encrypted SSH connections allow securely accessing your Pi and projects over untrusted networks.
Cost Saving – No need for a separate keyboard, mouse, monitor which simplifies your setup and saves money.
So if you want to access your headless Pi from anywhere, make managing and collaborating on projects easier, or build automated remote controlled systems – then setting up remote access is a must.
The Secure Shell Protocol (SSH) is likely the most common and universal method used to access command-line interfaces on Linux and other UNIX-based systems. It provides a secure encrypted connection over a network or the internet.
Enabling SSH access on your Raspberry Pi will allow you to remotely log in to the terminal just as if you were connected directly through a keyboard and display. This gives you full control to execute commands, edit files, run programs, and configure your Pi’s Linux operating system.
The only limitations are that you should have access to the network to which the Pi is connected, and this gives access to the only command-line interface. Let’s see how to connect to Pi using SSH.
Make sure SSH is enabled on the Pi. to ensure that, go to main menu -> preferences -> Raspberry Pi configuration as shown here. And go to the interfaces tab where you can enable the SSH and hit OK.
Alternatively, SSH can be enabled directly during the Raspberry Pi OS image writing process. When using Raspberry Pi Imager to write the OS image to a microSD card, click the gear icon to open settings. Under Interface Options, you can choose to enable SSH and select password or public key authentication.
As long as you’ve enabled SSH on your Pi, you can connect immediately using any SSH client.
Connecting from Windows: On Windows, you’ll need to install a third-party SSH client such as the popular PuTTY. Launch PuTTY, enter your Pi’s IP address, set the port to 22, and click Open to initiate the connection.
Login to Rasberry Pi using SSH
Connecting from Linux or Mac: On Linux and macOS which have built-in SSH clients, simply open a terminal and type:
ssh pi@192.168.0.100
Replace the IP address with your Raspberry Pi’s address. When prompted, enter the default password ‘raspberry’ and you’ll be logged in to your Pi’s terminal remotely!
Once connected over SSH, you’ll have full access to execute commands and transfer files as if you were logged in directly. This allows you to conveniently manage your Pi’s Linux operating system and install/run whatever server software you need for your projects.
Overall, SSH provides the fastest and simplest way to access your Pi’s command line remotely. The encrypted connection allows secure access over any network. Whether you just need occasional terminal access or plan to run headless server processes, enabling SSH is a necessity.
Options don’t end working with CLI. Most users want to use the GUI desktop over the network. The good news is that it is as simple as accessing the GUI desktop as CLI. There is a simple solution for this, XRDP. It is an open-source remote desktop protocol that allows you to connect remote desktops from any platform. This is a cross-platform protocol that works on a 3389 standard port. Just you need to allow this port on the system firewall. One downside is it can be used only inside the network. You need to install the XRDP and tight VNC server to take RDP sessions from the RDP client.
Open the terminal if you have direct access. Or, take an SSH session to the Raspberry Pi CLI.
To set up XRDP on Raspberry Pi. Open the terminal if you have direct access. Or, take an SSH session to the Raspberry Pi CLI.
$ sudo apt update && sudo apt upgrade
$ sudo apt install xrdp -y
$ sudo apt-get install tightvncserver -y
It takes a few minutes to install the packages.
$ sudo systemctl start xrdp
To start XRDP service at boot, use the enable command:
$ sudo systemctl enable xrdp
$ sudo netstat -tulpn | grep -i xrdp
Output:tcp 0 0 127.0.0.1:3350 0.0.0.0:* LISTEN 7534/xrdp-sesmantcp 0 0 0.0.0.0:3389 0.0.0.0:* LISTEN 7535/xrdp
That’s it. XRDP provides seamless remote desktop access on any device with minimal setup. But being network-reliant, it only works when connected to the same network as your Pi. For untethered internet access, VNC is a better fit.
Connecting from Linux client: Remmina, one such RDP client application is the best option to initiate an RDP connection to Pi. You can install the application by issuing the below command. It may take a couple of minutes, depending on your system and internet speed. It works only on the GUI desktop environment. This is a very cool application. It can work as RDP, SSH, and VNC client.
$ sudo apt-get install remmina, remmina-common, remmina-plugin-rdp
Connecting Raspberry Pi using a desktop SSH client
Connecting from Windows client: No additional programs are required to connect Raspberry Pi from a Windows computer. Windows has a built-in program called ‘Remote Desktop connection’.
Open the Run window by hitting ‘Windows Key’ + ‘R’ at the same time. Type ‘mstsc‘ to launch the Remote Desktop Connection window.
2. Type the Raspberry Pi’s IP address and optionally provide the login credentials too. Credentials could be supplied later as well. At last, hit ‘Connect’
VNC (Virtual Network Computing) is another common remote desktop protocol similar to XRDP. It allows you to remotely access and control the Raspberry Pi’s full graphical desktop.
There are many VNC server and client implementations available. The Raspberry Pi OS distro ships with RealVNC server pre-installed, making setup straightforward.
Once configured, you can connect to your Pi’s desktop from any VNC client app on Windows, Mac, Linux, iOS, Android, and more.
To enable RealVNC on your Pi:
Open the terminal and execute this command to launch the Raspberry Pi Software Configuration Tool.
sudo raspi-config
Select Interface Options and hit the Enter key.
Select Yes to enable VNC.
As soon as you enable the VNC service it generates a pair of cryptographic keys.
With the VNC server now running, install a VNC Viewer app on your computer or mobile device. Enter your Pi’s IP address and VNC password when connecting.
The Raspberry Pi desktop will then appear in your VNC Viewer app. You can access the GUI as if connected directly to a monitor, keyboard, and mouse.
VNC works well locally over LAN. For untethered internet access, set up port forwarding on your router or connect via VPN. The encryption negotiated by VNC keeps your connection secure.
Overall, VNC is cross-platform and reasonably straightforward to get running. It provides more flexible remote access than XRDP, at the cost of some speed. But for general GUI access from anywhere, VNC is a solid choice.
To keep this post simple, we have created another dedicated blog post to show you how to set up the VNC on the Raspberry Pi. Please visit the post “How to set up RealVNC on Raspberry Pi” to install and set up RealVNC manually on the Raspberry Pi.
All the methods covered so far require you to be on the same local network as the Raspberry Pi. But what if you want to access your Pi while away from home, like at a coffee shop or airport?
Virtual Private Networks (VPNs) allow you to remotely connect your device or computer to a home network. This gives you local network access to your Raspberry Pi from anywhere in the world!
A common way is using an OpenVPN server on your home router if it supports it. Otherwise, you can run an OpenVPN server directly on your Pi for secure remote access.
Here’s a quick summary, but we’ve published a full step-by-step guide for setting up a Raspberry Pi VPN server as a different post.
Run this command to install the OpenVPN package:
sudo apt install openvpn
Make a copy of the Easy-RSA certificate generation scripts:
cp -r /usr/share/easy-rsa/ /etc/openvpn
Go to the Easy-RSA directory. Generate the CA certificate and key:
sudo ./easyrsa init-pki
sudo ./easyrsa --batch build-ca nopass
Generate server certificate and key:
sudo ./easyrsa build-server-full server nopass
Generate client certificate and key:
sudo ./easyrsa build-client-full client1 nopass
Generate Diffie-Hellman key exchange:
sudo ./easyrsa gen-dh
Copy generated certificates and keys to /etc/openvpn:
sudo cp pki/ca.crt pki/issued/server.crt pki/private/server.key pki/dh.pem /etc/openvpn
Create server configuration file:
sudo nano /etc/openvpn/server.conf
Add OpenVPN settings to the file and save. Start OpenVPN server:
sudo systemctl start openvpn
That covers the basic setup. You’ll also need to configure routing and firewall rules as needed. Let me know if you need any clarification or have additional questions!
The methods covered so far provide standard ways to remotely connect to your Raspberry Pi using open protocols like SSH, VNC, RDP, and VPNs. However, there are also many excellent dedicated third-party services designed specifically for easy remote device access.
These services abstract away much of the manual setup and configuration required by traditional methods. They provide user-friendly apps, cloud platforms, and tight integration to make remotely connecting to your devices seamless.
Here are some top options to consider:
Chrome Remote Desktop by Google is a free and officially supported remote access solution for the Raspberry Pi. It offers native apps for Windows, Mac, Linux, iOS, and Android.
After installing the Chrome Remote Desktop package on your Pi, you simply log into a Google account on any Chrome browser or mobile app. Your Pi will appear as an available remote desktop target. Click to connect and you’re in!
Setup takes just minutes with no advanced network configuration needed. Streaming and audio support allow for very responsive connections. Being tied to your Google account makes things simple to access your Pi from anywhere.
TeamViewer is a popular proprietary software package for controlling computers and mobile devices remotely. It’s free for personal use and supports all major desktop and mobile platforms.
Preconfigured TeamViewer packages are available for Raspbian, making setup on your Pi a breeze. Remote connections are facilitated through TeamViewer’s global access infrastructure rather than requiring VPNs or port forwarding.
TeamViewer also provides capabilities like file transfer, screen sharing, remote printing, and VoIP chat. For general purpose remote control, TeamViewer works very well out of the box.
AnyDesk offers similar seamless remote device connectivity as TeamViewer. It’s also free for personal use and includes a preconfigured package to simplify Raspberry Pi setup.
AnyDesk provides responsive remote desktop control and file transfer across Windows, macOS, Linux, Android and iOS. Support for multiple monitors and high FPS screen sharing enhance the user experience.
With AnyDesk’s proprietary DeskRT technology, connections are optimized to be fast and reliable. Like TeamViewer, AnyDesk handles NAT traversal automatically without any network configuration.
Services like Splashtop, SupRemo, and Zoho Assist also make accessing your Pi and other remote devices straightforward. Browser-based solutions like Apache Guacamole and Cloud Commander are sometimes used as well.
And platforms like AWS, Azure, and Google Cloud also facilitate remote device monitoring and control via IoT services. It’s worth exploring solutions that provide libraries and SDKs for your projects and use cases.
So in summary, dedicated third-party services trade some control and customization for a dramatically simplified user experience. If you want reliable remote Pi access without the hassle, these services are definitely worth considering!
We hope this post helps you learn different ways to connect Raspberry Pi remotely over the network. Thanks for reading this tutorial post. Visit our website thesecmaster.com and social media page on Facebook, LinkedIn, Twitter, Telegram, Tumblr, Medium & Instagram, and subscribe to receive updates like this.
You may also like these articles:
Arun KL is a cybersecurity professional with 15+ years of experience in IT infrastructure, cloud security, vulnerability management, Penetration Testing, security operations, and incident response. He is adept at designing and implementing robust security solutions to safeguard systems and data. Arun holds multiple industry certifications including CCNA, CCNA Security, RHCE, CEH, and AWS Security.
“Knowledge Arsenal: Empowering Your Security Journey through Continuous Learning”
"Cybersecurity All-in-One For Dummies" offers a comprehensive guide to securing personal and business digital assets from cyber threats, with actionable insights from industry experts.
BurpGPT is a cutting-edge Burp Suite extension that harnesses the power of OpenAI's language models to revolutionize web application security testing. With customizable prompts and advanced AI capabilities, BurpGPT enables security professionals to uncover bespoke vulnerabilities, streamline assessments, and stay ahead of evolving threats.
PentestGPT, developed by Gelei Deng and team, revolutionizes penetration testing by harnessing AI power. Leveraging OpenAI's GPT-4, it automates and streamlines the process, making it efficient and accessible. With advanced features and interactive guidance, PentestGPT empowers testers to identify vulnerabilities effectively, representing a significant leap in cybersecurity.
Tenable BurpGPT is a powerful Burp Suite extension that leverages OpenAI's advanced language models to analyze HTTP traffic and identify potential security risks. By automating vulnerability detection and providing AI-generated insights, BurpGPT dramatically reduces manual testing efforts for security researchers, developers, and pentesters.
Microsoft Security Copilot is a revolutionary AI-powered security solution that empowers cybersecurity professionals to identify and address potential breaches effectively. By harnessing advanced technologies like OpenAI's GPT-4 and Microsoft's extensive threat intelligence, Security Copilot streamlines threat detection and response, enabling defenders to operate at machine speed and scale.