5

I am trying to install vnc on an x86_64 ubuntu 20.10 which is headless. I do NOT want Xfce, all of the tutorials for some inexplicable reason tell you to install xfce. I do NOT want to install this package as I already have the desktop manager: Gnome (default on Ubuntu).

As far as I can tell the guide on digital ocean seems to be the best except their xstartup is for xfce. I tried following and replaced xfce with gnome-session but I just get a grey screen and can't interact with anything.

could anyone please help me with this or point me in the right direction.

Thanks!

Edit: Here is my xstartup:

# Config requires following packages:
# gnome-panel nautilus gnome-terminal metacity
#


export XKL_XMODMAP_DISABLE=1

unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey

gnome-session &
gnome-panel &

metacity &
gnome-terminal &

I run vncserver via ssh on a remote machine using this:

$ vncserver

New 'X' desktop is media-server:1

Starting applications specified in /home/kevin/.vnc/xstartup
Log file is /home/kevin/.vnc/media-server:1.log

and here is the log:

04/02/21 10:40:28 Xvnc version TightVNC-1.3.10
04/02/21 10:40:28 Copyright (C) 2000-2009 TightVNC Group
04/02/21 10:40:28 Copyright (C) 1999 AT&T Laboratories Cambridge
04/02/21 10:40:28 All Rights Reserved.
04/02/21 10:40:28 See http://www.tightvnc.com/ for information on TightVNC
04/02/21 10:40:28 Desktop name 'X' (media-server:1)
04/02/21 10:40:28 Protocol versions supported: 3.3, 3.7, 3.8, 3.7t, 3.8t
04/02/21 10:40:28 Listening for VNC connections on TCP port 5901
Font directory '/usr/share/fonts/X11/75dpi/' not found - ignoring
Font directory '/usr/share/fonts/X11/100dpi/' not found - ignoring

(gnome-panel:123980): gnome-panel-WARNING **: 10:40:30.098: Failed to acquire bus name!
metacity-Message: 10:40:30.227: could not find XKB extension.

(metacity:123981): metacity-WARNING **: 10:40:30.232: Failed to create compositor: Missing composite extension required for compositing
Xlib:  extension "X-Resource" missing on display ":1".

Here is what I get when I try to view the desktop: VNC Connection

Kevin
  • 265
  • 3
  • 12
  • I do, I have gnome. I bolded that part of my question. – Kevin Feb 04 '21 at 02:45
  • Please [edit] your question to include the contents of your `xstartup` file - and also any relevant errors from the session log – steeldriver Feb 04 '21 at 14:14
  • @steeldriver Thank you, I have posted the xstartup and the logs when I start it. – Kevin Feb 04 '21 at 15:46
  • Sorry it's been a while since I played with any of this stuff - however I think you will be out of luck running metacity with the current (gnome3 based) session. It *used* to be possible to specify a gnome2 based "flashback" session via the `--session=` option but I'm not sure if that's possible any more (or, if it is, how). – steeldriver Feb 04 '21 at 16:35
  • @steeldriver No problem. Thanks for looking into it! – Kevin Feb 04 '21 at 22:05
  • So it looks like there **is** a [gnome-session-flashback package for groovy](https://packages.ubuntu.com/groovy/gnome-session-flashback). This walkthrough (for focal) may be helpful as well [How to Install Classic GNOME Flashback in Ubuntu 20.04 LTS](https://www.debugpoint.com/2020/04/how-to-install-classic-gnome-flashback-in-ubuntu-20-04-lts/) – steeldriver Feb 04 '21 at 22:24
  • @steeldriver Thank you again. Just paste this in an answer and I will mark it as accepted. – Kevin Feb 05 '21 at 13:49
  • Please consider writing your own answer instead, including the working .xstartup file - I'm sure it will help others. – steeldriver Feb 06 '21 at 14:55
  • you need to install xorg-dummy to create a display for vnc to export – JOHN GROSS Apr 11 '22 at 01:58

2 Answers2

6

Of course this is possible! There is nothing magical, Virtual display, desktop manager and VNC server are 3 pieces that must be put together correctly.

VNC server setup consists of 3 main steps:

  1. Xvfb - starting virtual display (can be used not only by GUI desktop, but could run apps like games or chromium directly in it)
export DISPLAY=:1
Xvfb $DISPLAY -screen 0 1024x768x16
  1. GUI session that connects to same Xvfb $DISPLAY and renders desktop there

For XFCE use this

sudo apt install xfce4 xfce4-goodies
xfce4-session # start xfce4

For default gnome use this:

gnome-shell --replace # start ubuntu gnome 
  1. xvnc server (tightvncserver or x11vnc). x11vnc way better, because Copy+Paste works out of box and Chromium apps work. tightvncserver does not work chromium apps. VNC server also connects to $DISPLAY and provides the access to clients outside. Do not run as sudo!
sudo apt install x11vnc

Password setup

x11vnc -storepasswd
x11vnc -display $DISPLAY -forever -loop -noxdamage -repeat -rfbauth /home/ubuntu/.vnc/passwd -rfbport 5900 -shared

Final script that you add to crontab crontab -e with @reboot /path/to/script.sh

Run scripts in background using & syntax

For XFCE

#!/bin/bash
source /home/ubuntu/.bashrc
export DISPLAY=:1
Xvfb $DISPLAY -screen 0 2048x1536x24 &
xfce4-session &
x11vnc -display $DISPLAY -forever -loop -noxdamage -repeat -rfbauth /home/ubuntu/.vnc/passwd -rfbport 5900 -shared &

For default gnome

#!/bin/bash
source /home/ubuntu/.bashrc
export DISPLAY=:1
Xvfb $DISPLAY -screen 0 2048x1536x24 &
gnome-shell --replace &
x11vnc -display $DISPLAY -forever -loop -noxdamage -repeat -rfbauth /home/ubuntu/.vnc/passwd -rfbport 5900 -shared &
Evalds Urtans
  • 176
  • 1
  • 4
  • Thanks for the answer! This works for running the script manually, but when I run this script via a service or crontab, gnome-shell isn't loaded. Any idea why? – mattideluxe Aug 29 '23 at 23:34
  • this works for me, the rest like install dummy not work. Any other long and many up votes dont work. But anydesk, xfce-terminal not work, get sig abort. Firefox and ms edge work – Tiana987642 Sep 03 '23 at 03:58
-2

This is not possible. You use VNC to remotely control a desktop but a headless system has no desktop and you don't want to install one.

So I guess what you want is access to a shell on your Ubuntu machine. This is what SSH is there for. As you mentioned Digital Ocean, here is a link to their SSH tutorial.

wedi
  • 269
  • 1
  • 2
  • 11