Table of Contents

  1. Settings
  2. Install VNC server
  3. Start VNC server
    1. idb conflict with conda
  4. Connect to VNC server
  5. References

First of all, what is VNC?

In computing, Virtual Network Computing is a graphical desktop-sharing system that uses the Remote Frame Buffer protocol to remotely control another computer. It transmits the keyboard and mouse events from one computer to another, relaying the graphical-screen updates back in the other direction, over a network. Wikipedia

Basically it’s a remote desktop controller for all platforms.

Settings

I was asked to start a VNC server on a CentOS remote machine, for people to access from Windows laptops. The CentOS server already has vncserver installed, also I am using conda on it.

Install VNC server

For completeness, I shall include a description of how to install VNC server.

  1. Install a desktop on the remote machine

We often access the remote server without GUI desktop. If it doesn’t have desktop installed, we need to do it ourselves.

For Ubuntu:

1
$ sudo apt-get install xfce xfce4-goodies -y

or for CentOS:
1
2
$ sudo yum -y groups install "GNOME Desktop"
$ startx

  1. Install vncserver

On Ubuntu:

1
$ sudo apt-get install tightvncserver -y

or on CentOS:
1
$ sudo yum install tigervnc-server

If the installation is successful, we should be able to run

1
$ vncserver

Start VNC server

Start VNC server by running:

1
$ vncserver

Check if it is running by checking the log:

1
2
3
4
5
6
7
8
9
10
11
12
13
(base) niansong@auros-gaming3e-2:~$ cat ~/.vnc/auros-gaming3e-2\:1.log
Xvnc TigerVNC 1.8.0 - built Nov 2 2018 19:05:14
Copyright (C) 1999-2017 TigerVNC Team and many others (see README.txt)
See http://www.tigervnc.org for information on TigerVNC.
Underlying X server release 12001000, The X.Org Foundation
Wed Feb 24 11:00:32 2021
vncext: VNC extension running!
vncext: Listening for VNC connections on all interface(s), port 5901
vncext: created VNC server for screen 0
GLib-GIO-Message: 11:00:36.261: Using the 'memory' GSettings backend. Your settings will not be saved or shared with other applications.
Wed Feb 24 11:00:36 2021
ComparingUpdateTracker: 0 pixels in / 0 pixels out
ComparingUpdateTracker: (1:-nan ratio)

If the log looks like this, no error or exiting, we are good.

idb conflict with conda

I got following complain in the log:

gnome-session[4099]: WARNING: Could not make bus activated clients aware of DISPLAY=:7 environment variable: Failed to connect to socket /tmp/dbus-TAq3EF94t4: Connection refusedß

After trying many methods, I found that it was a dbus conflict casued by conda (who could have thought). We need to uninstall the dbus module in conda:

1
2
$ conda uninstall dbus
$ conda uninstall --offline dbus # uninstall without internet

Connect to VNC server

We need to forward the display port to localhost, and then connect to it with VNC Viewer.

First we run this command:

1
$ ssh -L 5901:127.0.0.1:5901 -C -N -l <username> <ip>
  • 5901: the port at which vncserver is running, check it in the log. 5901 is the default number.
  • <username> is the username you input when running vncserver
  • ip is the server’s ip

In my case:

This command will hang in there, no output is normal. Then we connect to localhost:5901 on VNC Viewer:

If the connection is successful, we will be able to get the desktop GUI like this:

References

https://github.com/TigerVNC/tigervnc/issues/592
https://www.techrepublic.com/article/how-to-install-a-vnc-server-on-linux/
https://www.techrepublic.com/article/how-to-install-a-gui-on-top-of-centos-7/