How to Setup a Raspberry Pi Remote Desktop
Sometimes you need to access a Raspberry Pi without connecting it to a monitor, keyboard, and mouse. Perhaps the Raspberry Pi is embedded in a robot or mounted in an inconvenient location. Or maybe you don’t have a spare monitor. This guide will walk you through the steps to set up remote desktop access on your Raspberry Pi.
Remote Control Over the Local Network
To remotely control your Raspberry Pi from another device on your local network, use one of the following services:
SSH (Secure SHell)
SSH provides secure access to a terminal session on your Raspberry Pi.
-
Enable SSH on Raspberry Pi:
- On the desktop: Go to
Preferences
>Raspberry Pi Configuration
>Interfaces
and enable SSH. - From the terminal:
- On the desktop: Go to
sudo raspi-config
Select Interfacing Options
> SSH
> Yes
.
-
Find the IP Address:
- Use
hostname -I
or check your router's client list.
- Use
-
Connect via SSH:
- From another device, use an SSH client like PuTTY (Windows) or the terminal (macOS/Linux):
ssh pi@<your_raspberry_pi_ip>
Replace <your_raspberry_pi_ip>
with the actual IP address of your Raspberry Pi.
VNC (Virtual Network Computing)
VNC provides secure access to a desktop screen share on your Raspberry Pi.
-
Enable VNC on Raspberry Pi:
- On the desktop: Go to
Preferences
>Raspberry Pi Configuration
>Interfaces
and enable VNC. - From the terminal:
- On the desktop: Go to
sudo raspi-config
Select Interfacing Options
> VNC
> Yes
.
-
Install VNC Viewer:
- Download and install VNC Viewer on your client device from the RealVNC website.
-
Connect via VNC:
- Open VNC Viewer and enter the IP address of your Raspberry Pi to connect.
Raspberry Pi Connect
Raspberry Pi Connect shares your Raspberry Pi’s screen securely with no need to determine your local IP address.
Share Files Between Devices Over the Local Network
NFS (Network File System)
NFS enables you to share files between devices on the local network without directly controlling the remote device.
- Install NFS on Raspberry Pi:
sudo apt install nfs-kernel-server
-
Configure NFS Exports:
- Edit
/etc/exports
to add the directories you want to share:
- Edit
/home/pi/shared 192.168.1.0/24(rw,sync,no_subtree_check)
- Export the Shared Directories:
sudo exportfs -a
sudo systemctl restart nfs-kernel-server
SCP (Secure Copy Protocol)
SCP sends files over SSH.
- Copy Files to Raspberry Pi:
scp myfile.txt pi@<your_raspberry_pi_ip>:/home/pi/
- Copy Files from Raspberry Pi:
scp pi@<your_raspberry_pi_ip>:/home/pi/myfile.txt .
Remote Control Over the Internet
To remotely control your Raspberry Pi from any device connected to the Internet, you can:
- Expose SSH or VNC on your Raspberry Pi over the open internet, within a VPN, or using an external service like RealVNC’s cloud VNC Viewer.
- Use Raspberry Pi Connect, a free screen sharing and remote shell service provided by Raspberry Pi.
Find the IP Address of Your Raspberry Pi
Using the Desktop
Hover over the network icon in the system tray, and a tooltip will appear displaying your IP address.
Using the Command Line
Run the following command to output your local IP address to the command line:
hostname -I
Using Network Manager
Use the built-in Network Manager CLI (nmcli) to access details about your network:
nmcli device show
Check Your Router’s List of Devices
Log in to your router’s control panel and browse to the list of connected devices to find your Raspberry Pi.
Use nmap
The Network Mapper command (nmap) can scan devices on your network:
sudo apt install nmap
sudo nmap -sn 192.168.1.0/24
Access a Remote Terminal with SSH
Enable the SSH Server
- On the desktop:
Preferences
>Raspberry Pi Configuration
>Interfaces
>Enable SSH
- From the terminal:
sudo raspi-config
Select Interfacing Options > SSH > Yes`
Connect to an SSH Server
Open a terminal window on your computer and enter:
ssh pi@<your_raspberry_pi_ip>
Screen Share with VNC
Enable the VNC Server
- On the desktop:
Preferences
>Raspberry Pi Configuration
>Interfaces
>Enable VNC
- From the terminal:
sudo raspi-config
Select Interfacing Options > VNC > Yes`
Connect to a VNC Server
Download VNC Viewer and connect using the IP address of your Raspberry Pi.
Conclusion
Setting up remote desktop access on your Raspberry Pi is essential for managing your device without the need for a monitor, keyboard, or mouse. Whether you use SSH, VNC, or other services, this guide provides you with the steps to remotely access and control your Raspberry Pi. Enjoy the flexibility of managing your Raspberry Pi from anywhere in your local network or even over the internet!