Virtual Network Computing

Sources:

Virtual Network Computing

VNC stands for Virtual Network Computing. It is a protocol for sharing a Linux desktop remotely. VNC operates on a client-server model, allowing you to control or access a graphical desktop over the network.

Common implementations include: - TigerVNC (supports GLX) - TightVNC (does NOT support GLX) Source - Vino (GNOME default) - x11vnc - krfb (KDE default) - vnc4server

VNC vs. X11 Forwarding

X11 Forwarding only forwards window events. It doesn't display the full desktop and may fail to handle complex graphics (e.g., XQuartz on MacOS fails to handle OpenGL). VNC streams the entire desktop session and is more robust, especially for headless or graphical applications.

TigerVNC (Supports GLX)

TigerVNC supports OpenGL rendering (GLX). It's recommended for graphical or headless environments. Meanwhile, it's preferred to use XFCE as desktop enviroment instead of GNOME, as some systems may have issues with GNOME.

  1. Install XFCE Desktop Environment

    1
    2
    sudo apt update
    sudo apt install xfce4 xfce4-goodies
  2. Install TigerVNC

    1
    sudo apt install tigervnc-standalone-server

    Initialize the server:

    1
    vncserver

    You will be prompted to set a password. A default instance starts on port 5901 (:1), then 5902 (:2), etc.

  3. Configure VNC Startup

    Kill the running server:

    1
    vncserver -kill :1

    Edit the startup script:

    1
    vim ~/.vnc/xstartup

    Insert

    1
    2
    3
    4
    5
    6
    7
    #!/bin/sh
    unset SESSION_MANAGER
    unset DBUS_SESSION_BUS_ADDRESS
    /usr/bin/startxfce4
    [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
    [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
    x-window-manager &

    Make it executable:

    1
    chmod +x ~/.vnc/xstartup
  4. Restart VNC server:

    1
    vncserver -localhost no :1

    By default, TigerVNC accepts connection only from 127.0.0.1 or localhost for security reasons. The -localhost no flag allows connections from outside localhost.

Common Commands

Run the VNC server:

1
vncserver -localhost no :1

Kill VNC:

1
vncserver -kill :1

TightVNC (No GLX Support)

-->How to Install and Configure VNC on Ubuntu 20.04

TightVNC listens on port 5901. It is lightweight but lacks OpenGL support.

x11vnc (Supports GLX)

Setup x11vnc Server Alternative Guide

x11vnc connects to an existing X session. It mirrors what a user physically sitting at the machine would see.

Limitations:

  • Requires an active display.
  • Doesn't work on headless servers unless a dummy display is set up.
  • Listens on port 5900.

Connecting to VNC

You can connect using VNC Viewer.

macOS users can use Finder:

  1. Open Finder > Go > Connect to Server...
  2. Enter: vnc://<hostname>:<port>
  3. Click "Connect"