Most articles that discuss logging into your Raspberry Pi remotely use
xrdp to create Remote Desktop sessions into your Raspberry Pi. This is often a good solution, and works even if you do not have a physical monitor connected to your Raspberry Pi. But there are times when you actually want to remotely take control of the desktop that is currently being displayed on the physical monitor connected to the Raspberry Pi, rather can creating a new desktop session (which is how
xrdp works). This article explains how to remotely control the desktop currently being displayed on your Raspberry Pi.
Step 1: Open a Terminal Port
Boot up the Raspberry Pi and open a terminal port.
Step 2: Install X11vnc
Enter the following command to install
x11vnc (more information about
x11vnc can be found at http://www.karlrunge.com/x11vnc/):
sudo apt-get install x11vnc
Step 3: Setup VNC Password
Enter the following command to set the VNC password:
This is the password users will need to enter when connecting to the Raspberry Pi.
Step 4: Determine the Raspberry Pi's IP Address
You will need to know the Raspberry Pi's IP Address to remotely connect to it. This can be done by executing the following command from a terminal prompt:
Step 5: Test the X11vnc Server
You can test the
x11vnc server by entering the following at a terminal prompt:
Step 6: Testing X11vnc Server
x11vnc server is running, you should see a message like the one shown above in your terminal window.
Step 7: Installing a VNC Client
To remotely control the Raspberry Pi using Microsoft Windows, you will need to install a VNC client. For this example I am using the TightVNC Viewer (http://www.tightvnc.com/download.php). Download and install this application.
Step 8: Run VNC Client
Start the TightVNC Viewer and enter the IP address of the Raspberry Pi followed by a “:” and the display number, which can be found in the terminal window running
x11vnc (this will normally be a 0, but in our example it happens to be a 2).
Step 9: Enter the VNC Password
Enter the password that was used when setting up
You should now see and able to control the desktop of the Raspberry Pi.
Step 10: Automatically Startup X11vnc on the Raspberry Pi
Complete the following steps if you want the
x11vnc server to automatically startup anytime you boot your Raspberry Pi.
Create the directory
~/.config/autostart, if it does not already exist. This can be done using the following terminal command:
mkdir –p ~/.config/autostart
Step 11: Create Xterm-autostart.desktop
Create a text file in this directory, called
xterm-autostart.desktop. You can create and edit this file with the following terminal command.
Step 12: Populate the Xterm-autostart.desktop File
Put the following text into this file:
[Desktop Entry] Encoding=UTF-8 Name=x11vnc autostart Comment=Starts the x11vnc server to allow for remote VNC connections. Exec=x11vnc –forever -usepw
Step 13: Reboot Raspberry Pi
Reboot the Raspberry Pi.
Once the Raspberry Pi desktop appears, you should be able to remote control the Raspberry Pi using any VNC Client.
Participated in the
Raspberry Pi Contest 2016
whitev6 made it!