Ubuntu – Enable VNC on Ubuntu 18.04 Minimal Installation

18.04vnc

I installed Ubuntu 18.04 desktop with minimal installation on my mac mini. It however doesn't come with remote desktop.

I already have ssh access. So how can I, through terminal, enable and configure VNC remote access from both the local IP address (192.168.1.x) and its FQDN?

I want to use the default display manager and desktop interface for Bionic Beaver.

Notes:

  • I don't have any monitor attached
  • I want to use the default window manager (xorg)
  • I want to use the default desktop environment
  • I did minimal installation when installing Ubuntu Desktop

Best Answer

To your working ssh setup, add a vnc server like x11vnc to your server and a viewer like xtightvncviewer to your remote machine. For outside the local network, ensure you have a passthrough for your ssh (port 5900 will be tunneled, so nothing special needed for it). X should be running on the server, but no existing login is needed (you will connect to the login screen). No other special services needed on the server.

From the remote, use ssh to start the x11vnc server, and tunnel port 5900 back to the remote (assumed to be on ...131 on the local network). In a terminal type:

ssh -t -L 5900:localhost:5900 192.168.1.131 "sudo x11vnc -localhost -create -auth guess  -display :0"

The output should indicate a successful connection. Leave this terminal and in another, start the vnc viewer on the (tunneled local port 5900):

xtightvncviewer -encodings RRE -bgr233 localhost::5900

The encodings and option improve performance for me, but are optional. A new window should open with the server login screen displayed. Login to the desktop you set up.

If you want to leave the server program running over multiple invocations of the viewer, you may use the -forever option, but with the above, the server will close the x11vnc program when the viewer exits.