Connect to Existing Running Desktop Session using x11vnc


April 21, 2021

In this post, we are looking to connect to an existing running desktop session using a VNC server. Imagine you would like to connect to your dual monitor desktop PC in your office from your home PC. Something very similar to what TeamViewer does for you. Thanks to the x11vnc project, now this can be easily achievable.

x11vnc dual monitor

Please note that you might need to create a tunnel if your workstation in your office does not have a static IP address (i.e. it is behind the NAT). In order to get connected to your machine you may find this article helpful.

Getting Started

We use Ubuntu Desktop 18.04 to run x11vnc and connect to it. If you use a different distribution of Linux, please check x11vnc page to find out how to install it.

Install x11vnc

sudo apt-get install x11vnc -y

Running x11vnc

For the first time, set the password for x1vnc using:

x11vnc -storepasswd

Once you set your password, you can run the server by:

x11vnc -rfbauth .vnc/passwd -display :0

Using x11vnc to Connect to Multiple Displays

If you are using multiple monitors, you will see both displays next to each other. To limit the part of the screen that is shown, you can use -clip parameters and specify which monitor you would like to get:

# To get the first monitor
x11vnc -rfbauth .vnc/passwd -clip xinerama0 -display :0 

# To get the second monitor
x11vnc -rfbauth .vnc/passwd -clip xinerama1 -display :0 

Linux VNC Ubuntu Remote