Software - Configuring VNC on Ubuntu 22.04 LTS

This is a guide on how to set up VNC on Ubuntu 22.04 LTS.

Prerequisites

  • Access to a local admin account
  • This guide assumes you have GNOME installed and it is functional i.e. you can log into a GUI on your Ubuntu machine with no issues.
  • The xstartup configurations in this guide only work with GNOME. If you're using a different GUI (KDE, xfce) then this will not work.
  • UFW is disabled by default on Ubuntu. If it is enabled, you will need to allow port range 5900 to 5910. Allow more ports if more VNC sessions will be used.
  • X11Forwarding enabled and set to yes in /etc/ssh/sshd_config

Installing Dependencies

Run the following as a local admin on the Ubuntu machine:

sudo apt install tightvncserver gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal xserver-xorg-core -y

Configure VNC

Do the following steps as your user account.

  1. Log in as the user you will use to connect to VNC.
  2. Run the following command:
    • vncpasswd
  3. Enter in a VNC password that will be used to connect to your account.
  4. Would you like to enter a view-only password (y/n)? n
  5. Start a new VNC session to populate the initial xstartup script in ~/.vnc
    • vncserver :1
  6. Kill the session
    • vncserver -kill :1
  7. Modify the ~/.vnc/xstartup script so it looks like this:
    #!/bin/sh
    
    unset SESSION_MANAGER
    unset DBUS_SESSION_BUS_ADDRESS
    
    [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
    [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
    
    export XKL_XMODMAP_DISABLE=1
    export XDG_CURRENT_DESKTOP="GNOME-Flashback:Unity"
    export XDG_MENU_PREFIX="gnome-flashback-"
    
    gnome-session --session=gnome-flashback-metacity --disable-acceleration-check &
    
  8. Start a new VNC session again.
    • vncserver :1
  9. Using a VNC client, connect to your Ubuntu machine's VNC server.
    • If you started vncserver on :1, then your port will be 5901 -- if you started vncserver on :2, then your port will be 5902 (and so on...).
    • You typically input the VNC server as IP-Address:Port
      • Example: 127.0.0.1:5901


Keywordssoftware configure vnc ubuntu 22.04 lts tightvnc gnome desktop jammy-jellyfish jammy jellyfish   Doc ID127360
OwnerJeremy H.GroupCALS Biochemistry IT
Created2023-04-19 08:08:06Updated2024-04-18 15:15:30
SitesCALS Biochemistry Information Technology
Feedback  2   3