Ubuntu – Running VNC server on Ubuntu Desktop 18.04 by creating new sessions

18.04gnomeremote desktopvnc

I would like to create a VNC server that runs gnome-shell environment, the same as the default UI in the console, separate from the console session (so that the console cannot see anything).

I tried vnc4server and tightvncserver, neither worked. No matter how I configured xstartup, gnome-session just won't run. I did manage to run Xfdm and gnome-panel in the same way. When I try to connect to the VNC server I get only grey screen. However I can confirm that the vnc server worked because I can run programs in it by setting DISPLAY and XAUTHORITY.

Is there a way to get ubuntu-desktop running in a new X session, separate from the console session? Preferably on a VNC server?

Steps I created the vnc server:

  1. Install a completely new Ubuntu 18.04 LTS Desktop.
  2. Install tightvncserver.
  3. Run vncserver to configure and kill it.
  4. Change ~/.vnc/xstartup and append:

    export STARTUP="/usr/bin/gnome-session –session=ubuntu –disable-acceleration-check"
    $STARTUP

  5. Run vncserver.

  6. Connect to the VNC server with any VNC client. Only grey screen is shown.
  7. Configure DISPLAY and XAUTHORITY and run gedit. The VNC session sees an incomplete gedit window.

Best Answer

Finally I found the solution.

The Gnome session doesn't seem to work on VNC X servers, but an Xvfb will work. The idea is to create an Xvfb for the session and use x11vnc for VNC:

Xvfb :1 -screen 0 1280x720x24

Then spawn GNOME environment:

DISPLAY=:1 gnome-shell --replace

Finally use x11vnc to create an VNC server for Xvfb:

x11vnc -display :1