How to install, connect to, restart, and change the password for a GUI interface on Ubuntu 22.04 using VNC server.

Installing GUI

1. Within the instance, run the following commands:

sudo apt install xfce4 xfce4-goodies -y # Install XFCE4 desktop environment 
sudo apt install tightvncserver -y # Install VNC server 
vncserver # Start VNC server

2. You will be prompted to create a VNC password.

When prompted with whether you want to create a view-only password, feel free to say No unless you want to create a pathway for users to log in without having any edit access. This can be changed later.

3. Run the following:

vncserver -kill :1 # Stop VNC server to edit configuration 
echo "startxfce4" >> ~/.vnc/xstartup # Starting XFCE4 desktop environment 
vncserver # Start VNC server again

4. SSH into and forward port 5901 where the GUI connection lives:

  • Standard SSH:
ssh -i path/to/private_key.key -L 5901:localhost:5901 ubuntu@your-vm-ip
  • Managed SSH through Oracle Cloud Bastion:
ssh -i path/to/private_key.key -o ProxyCommand="ssh -i path/to/private_key.key -W %h:%p -p 22 @host.bastion.us-ashburn-1.oci.oraclecloud.com" -p 22 -L 5901:localhost:5901 ubuntu@your-vm-ip

5. Install RealVNC Viewer and connect to address localhost:5901

Screenshot of Ubuntu GUI through RealVNC Viewer after connecting to localhost:5901
Screenshot of Ubuntu GUI through RealVNC Viewer after connecting to localhost:5901

Change GUI password

To change the GUI password, follow these steps.

  1. First kill any running VNC server:
vncserver -kill :1

2. Run the password command:

vncpasswd

3. Enter your new password when prompted (you'll need to type it twice)

4. Restart your VNC server:

vncserver

Starting the VNC Server

If you stop your instance, the VNC Server will stop as well. Starting back your instance will not start the VNC Server automatically. To start the VNC Server after a server startup, connect to the server via SSH, then run:

vncserver

References

  1. YouTube--Install Desktop GUI in Ubuntu Server on Oracle Cloud and configure Free RDP connection

Safe harbor statement

The information provided on this channel/article/story is solely intended for informational purposes and cannot be used as a part of any contractual agreement. The content does not guarantee the delivery of any material, code, or functionality, and should not be the sole basis for making purchasing decisions. The postings on this site are my own and do not necessarily reflect the views or work of Oracle or Mythics, LLC.

This work is licensed under a Creative Commons Attribution 4.0 International License.