Search

Friday, March 6, 2020

Remote Desktop Access to Real desktop on Linux using x11vnc (tested on Ubuntu and MX Linux)

Supratim Sanyal's blog: VNC remote desktop access to real screen of MX Linux using x11vnc
Remote Desktop Access over VNC to real screen of MX Linux 


Supratim Sanyal's blog: VNC remote desktop access to real screen of Ubuntu MATE linux using x11vnc
Remote Desktop Access over VNC to real screen of Ubuntu MATE
I have installed numerous VNC servers on Linux desktops over the years to access their graphical desktops remotely. This typically involved installing and launching an X server separate from the one serving the local desktop screen, along with a corresponding window manager and session manager different from the ones serving the local GUI desktop. This resulted in a different desktop being presented to VNC clients accessing the remote server. This desktop was independent of the actual ("real") desktop running on the remote machine's screen, which specifically made it impossible to access any open applications on the "real" desktop remotely.

The solution is to install x11vnc which presents the "real" desktop to VNC clients. I found and installed x11vnc from standard repositories on Ubuntu MATE and MX Linux. x11vnc works great on both distributions.

Here are my notes on how to do this.

Download and install x11vnc (and screen utility that we will use to run x11vnc) the usual way from repos:

# apt-get update
# apt-get install x11vnc screen


After downloading and installing x11vnc, as root create a VNC authentication password by entering the command:

# x11vnc -storepasswd
Enter VNC password: 
Verify password:    
Write password to /root/.vnc/passwd?  [y]/n y

Password written to: /root/.vnc/passwd

Then add the following to root's crontab (by running crontab -e):

#x11vnc - allow VNC connections to real X11 display
@reboot screen -S X11VNC-SERVER -m -d nice -n 19 ionice -c 3 x11vnc -usepw -nevershared -forever -no6 -display :0 -auth guess -loop


To start x11vnc right now instead of having to wait for the next reboot, type in:

screen -S X11VNC-SERVER -m -d nice -n 19 ionice -c 3 x11vnc -usepw -nevershared -forever -no6 -display :0 -auth guess -loop


Note: for enhanced security, you can limit x11vnc to listen to a specific interface by specifying the IP address of the interface to listen to using the additional switch "-listen ipaddr". From the man page:

-listen ipaddr         listen for connections only on network interface with addr ipaddr. '-listen localhost' and hostname work too.


Check if the screen session is indeed up. For example,

# screen -ls
There are screens on:
16484.X11VNC-SERVER (03/06/2020 06:53:47 AM) (Detached)

Also check the actual screen contents. Continuing our example:

# screen -r 16484
06/03/2020 06:53:49 rfbListenOnTCP6Port: error in bind IPv6 socket: Address family not supported by protocol
06/03/2020 06:53:49 rfbListenOnTCP6Port: error in bind IPv6 socket: Address family not supported by protocol
06/03/2020 06:53:49 Failure autoprobing: Address family not supported by protocol
06/03/2020 06:53:49
06/03/2020 06:53:49 Xinerama is present and active (e.g. multi-head).
06/03/2020 06:53:49 Xinerama: number of sub-screens: 1
06/03/2020 06:53:49 Xinerama: no blackouts needed (only one sub-screen)
06/03/2020 06:53:49
06/03/2020 06:53:49 fb read rate: 1371 MB/sec
06/03/2020 06:53:49 fast read: reset -wait  ms to: 10
06/03/2020 06:53:49 fast read: reset -defer ms to: 10
06/03/2020 06:53:49 The X server says there are 10 mouse buttons.
06/03/2020 06:53:49 screen setup finished.
06/03/2020 06:53:49

The VNC desktop is:      dell-poweredge-r710:0
PORT=5900

******************************************************************************
Have you tried the x11vnc '-ncache' VNC client-side pixel caching feature yet?

The scheme stores pixel data offscreen on the VNC viewer side for faster
retrieval.  It should work with any VNC viewer.  Try it by running:

    x11vnc -ncache 10 ...

One can also add -ncache_cr for smooth 'copyrect' window motion.
More info: http://www.karlrunge.com/x11vnc/faq.html#faq-client-caching

Press Control-a and then d to detach from the screen session (x11vnc keeps running inside the detached screen).

The "PORT=900" on the screen above confirms VNC server is listening on port 5900. We can, therefore, run a VNC client on a remote computer and point it to x11vnc server's and port 5900 to access the desktop over network. For example, from a remote client (I installed the tigervnc-viewer package on a remote MX Linux laptop to get vncviewer ):

$ vncviewer dell-poweredge-r710:5900

You will be asked to enter the VNC authentication password and then the remote X Windows desktop will be displayed on your screen.

TigerVNC viewer on MX Linux laptop displays remote Ubuntu desktop running SANYALnet Labs virtual boxes
TigerVNC viewer on MX Linux laptop displays remote Ubuntu desktop running SANYALnet Labs virtual boxes

No comments:

Post a Comment

"SEO" link builders: move on, your spam link will not get posted.

Note: Only a member of this blog may post a comment.

Recommended Products from Amazon