Development Linux

Startx as non-root user via SSH

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?

Leave a Reply

Your email address will not be published. Required fields are marked *