using Xvfb on virtual remote ssh server to have X graphical programs work

The scenario here is that you have some sort of remote headless Linux server but would like to run some programs on them and get graphical access to them.  The problem is that the remote server may be an image or VM without any virtual GPU and even if so, it is likely without KDE or Gnome, so there's no real way to do this, unless you follow our guide.

Install xvfb

apt install xvfb
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following additional packages will be installed:
  libxfont1 libxkbfile1 x11-xkb-utils xauth xfonts-base xfonts-encodings xfonts-utils xserver-common
The following NEW packages will be installed:
  libxfont1 libxkbfile1 x11-xkb-utils xauth xfonts-base xfonts-encodings xfonts-utils xserver-common
  xvfb
0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded.
Need to get 7703 kB of archives.
After this operation, 13.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu xenial/main amd64 xauth amd64 1:1.0.9-1ubuntu2 [22.7 kB]
Get:2 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libxfont1 amd64 1:1.5.1-1ubuntu0.16.04.4 [95.0 kB]
Get:3 http://archive.ubuntu.com/ubuntu xenial/main amd64 libxkbfile1 amd64 1:1.0.9-0ubuntu1 [65.1 kB]
Get:4 http://archive.ubuntu.com/ubuntu xenial/main amd64 x11-xkb-utils amd64 7.7+2 [153 kB]
Get:5 http://archive.ubuntu.com/ubuntu xenial/main amd64 xfonts-encodings all 1:1.0.4-2 [573 kB]
Get:6 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 xfonts-utils amd64 1:7.7+3ubuntu0.16.04.2 [74.6 kB]
Get:7 http://archive.ubuntu.com/ubuntu xenial/main amd64 xfonts-base all 1:1.0.4+nmu1 [5914 kB]
Get:8 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 xserver-common all 2:1.18.4-0ubuntu0.8 [27.7 kB]
Get:9 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 xvfb amd64 2:1.18.4-0ubuntu0.8 [777 kB]
Fetched 7703 kB in 1s (4446 kB/s)
Selecting previously unselected package xauth.
(Reading database ... 51038 files and directories currently installed.)
Preparing to unpack .../xauth_1%3a1.0.9-1ubuntu2_amd64.deb ...
Unpacking xauth (1:1.0.9-1ubuntu2) ...
Selecting previously unselected package libxfont1:amd64.
Preparing to unpack .../libxfont1_1%3a1.5.1-1ubuntu0.16.04.4_amd64.deb ...
Unpacking libxfont1:amd64 (1:1.5.1-1ubuntu0.16.04.4) ...
Selecting previously unselected package libxkbfile1:amd64.
Preparing to unpack .../libxkbfile1_1%3a1.0.9-0ubuntu1_amd64.deb ...
Unpacking libxkbfile1:amd64 (1:1.0.9-0ubuntu1) ...
Selecting previously unselected package x11-xkb-utils.
Preparing to unpack .../x11-xkb-utils_7.7+2_amd64.deb ...
Unpacking x11-xkb-utils (7.7+2) ...
Selecting previously unselected package xfonts-encodings.
Preparing to unpack .../xfonts-encodings_1%3a1.0.4-2_all.deb ...
Unpacking xfonts-encodings (1:1.0.4-2) ...
Selecting previously unselected package xfonts-utils.
Preparing to unpack .../xfonts-utils_1%3a7.7+3ubuntu0.16.04.2_amd64.deb ...
Unpacking xfonts-utils (1:7.7+3ubuntu0.16.04.2) ...
Selecting previously unselected package xfonts-base.
Preparing to unpack .../xfonts-base_1%3a1.0.4+nmu1_all.deb ...
Unpacking xfonts-base (1:1.0.4+nmu1) ...
Selecting previously unselected package xserver-common.
Preparing to unpack .../xserver-common_2%3a1.18.4-0ubuntu0.8_all.deb ...
Unpacking xserver-common (2:1.18.4-0ubuntu0.8) ...
Selecting previously unselected package xvfb.
Preparing to unpack .../xvfb_2%3a1.18.4-0ubuntu0.8_amd64.deb ...
Unpacking xvfb (2:1.18.4-0ubuntu0.8) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for libc-bin (2.23-0ubuntu11) ...
Processing triggers for fontconfig (2.11.94-0ubuntu1.1) ...
Setting up xauth (1:1.0.9-1ubuntu2) ...
Setting up libxfont1:amd64 (1:1.5.1-1ubuntu0.16.04.4) ...
Setting up libxkbfile1:amd64 (1:1.0.9-0ubuntu1) ...
Setting up x11-xkb-utils (7.7+2) ...
Setting up xfonts-encodings (1:1.0.4-2) ...
Setting up xfonts-utils (1:7.7+3ubuntu0.16.04.2) ...
Setting up xfonts-base (1:1.0.4+nmu1) ...
Setting up xserver-common (2:1.18.4-0ubuntu0.8) ...
Setting up xvfb (2:1.18.4-0ubuntu0.8) ...
Processing triggers for libc-bin (2.23-0ubuntu11) ...

Configure and run xvfb

First start the Xvfb server:

Xvfb&

Then use the xvfb-run command to start any program that needs graphical capabilities

xvfb-run someprogram

Nice Wrapper Script with VNC access

install x11vnc:

apt install x11vnc


/usr/bin/Xvfb :99 -ac  -screen 0 1280x720x16&
export DISPLAY=:99
x11vnc -display :99 -localhost&
 

If this was a docker container or something else you don't care about security on you can change the x11vnc line to this (remove localhost):

x11vnc -display :99&

Once x11 vnc display starts it will normally run on port 5900 unless something else is already uses, it then it might run on port 5901.

The above will give you a screen with 1280x720 and 16 bit color as Xorg server screen#99. The 16-bit color is important otherwise, you'll get a horrible black and white screen over VNC if you try to use it.

Then we use x11vnc to tap into Xorg display#99 and listen on our local host.

The result over VNC is this:

The example below is running Firefox on a remote Linux Root/VPS server without any X windows running or installed and connecting over VNC via localhost SSH port forwarding.

 


Tags:

xvfb, virtual, ssh, server, graphical, programs, workinstall, apt, install, lists, dependency, additional, packages, installed, libxfont, libxkbfile, xkb, utils, xauth, xfonts, encodings, xserver, upgraded, newly, kb, archives, mb, disk, http, archive, ubuntu, xenial, amd, updates, nmu, fetched, selecting, previously, unselected, database, directories, currently, preparing, unpack, xauth_, _amd, deb, unpacking, _, utils_, encodings_, _all, base_, common_, xvfb_, processing, triggers, db, libc, bin, fontconfig, configure, capabilities, someprogram,

Latest Articles

  • python mysql install error: /bin/sh: 1: mysql_config: not found /bin/sh: 1: mariadb_config: not found /bin/sh: 1: mysql_config: not found mysql_config --version
  • FreePBX 17 How To Add a Trunk
  • Docker Container Onboot Policy - How to make sure a container is always running
  • FreePBX 17 How To Add Phones / Extensions and Register
  • Warning: The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes. solution
  • Cisco How To Use a Third Party SIP Phone (eg. Avaya, 3CX)
  • Cisco Unified Communication Manager (CUCM) - How To Add Phones
  • pptp / pptpd not working in DD-WRT iptables / router
  • systemd-journald high memory usage solution
  • How to Install FreePBX 17 in Linux Debian Ubuntu Mint Guide
  • How To Install Cisco's CUCM (Cisco Unified Communication Manager) 12 Guide
  • Linux Ubuntu Redhat How To Extract Images from PDF
  • Linux and Windows Dual Boot Issue NIC Won't work After Booting Windows
  • Cisco CME How To Enable ACD hunt groups
  • How to install gns3 on Linux Ubuntu Mint
  • How to convert audio for Asterisk .wav format
  • Using Cisco CME Router with Asterisk as a dial-peer
  • Cisco CME How To Configure SIP Trunk VOIP
  • Virtualbox host Only Network Error Failed to save host network interface parameter - Cannot change gateway IP of host only network
  • Cisco CME and C7200 Router Testing and Learning Environment on Ubuntu 20+ Setup Tutorial Guide