I have a remote VM running Ubuntu 1804 and would like to run VNC. I am using x11vnc, which requires an X server to be running. Currently, I'm connected through SSH.

The VM has an Nvidia card, and after generating the xorg.conf with nvidia-xconfig, I can start an X session using startx, but only as root. Any subsequent connection via VNC is with root, which I want to avoid.

The Device section in xorg.conf file looks like this:

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "Tesla K80"
    BusID          "0:30:0"

When trying to launch startx as a non-root user, I get the following:

/usr/lib/xorg/Xorg.wrap: Only console users are allowed to run the X server

If I change the /etc/X11/Xwrapper.config to allow anybody to startx, I get the following:

Couldn't get a file descriptor referring to the console

I've been reading that connecting via SSH doesn't mean that you're connected to a text console, which you need to run startx. Trying to change to a text console with chvt fails doesn't change anything.

Is there anyway that I can launch X via SSH?

2 Answers 2


You can add a login manager (say, lightdm) and configure autologin. Even run x11vnc at the start of the user's sesion.

Alternatively you can run vncserver as the user and then connect directly to it, via ssh forwarding:

ssh -L5904:localhost:5905 user@example.com
vncserver :5 # only if the server has not been started

and then, on the client you can run:

xvncviewer localhost:4
  • I previously tried doing this and just tried again. If I do this, then X is started by vncserver. If this happens then I don't have the hardware acceleration with the GPU (checked with glxinfo). This is why I think I have to start X separately. Nov 26, 2019 at 18:02
  • Ok, you need hardware acceleration. Does the autologin work for you? I don't see how you profit from acceleration though once you pipe your session through x11vnc though. You are going to be running VNC on top of X in that case. Nov 26, 2019 at 18:13
  • I'll be trying soon. I need hardware acceleration because I'm rendering with Blender and it requires OpenGL through X (no support for EGL) for the Eevee renderer. Nov 27, 2019 at 9:40
  • Lightdm doesn't work as Xorg is also launched by root. I tried xhost + for the root X display and then x11vnc -users +ubuntu but that still is only in root mode. Nov 27, 2019 at 12:38
  • With lightdm you would not be doing startx, the X server would be brought up by lightdm itself (that's how normal desktops work). Then, the autologin feature will land you into the user you want to start the session as. Nov 27, 2019 at 14:21

Here is a solution based on systemd-run, it tricks startx into thinking that it has been run from a virtual terminal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.