What is Oracle Cloud?
Oracle Cloud is a cloud computing service offered by Oracle Corporation. It provides a range of cloud services, including:
- Infrastructure as a Service (IaaS): This includes virtual machines, storage, and networking resources.
- Platform as a Service (PaaS): Offers tools for developing, managing, and deploying applications, including databases, application development, and integration services.
- Software as a Service (SaaS): Provides ready-to-use software applications hosted in the cloud, such as enterprise resource planning (ERP), human capital management (HCM), and customer relationship management (CRM) applications.
Oracle Cloud is known for its strong emphasis on database solutions, high-performance computing, and enterprise applications. It aims to help businesses reduce IT costs, scale their operations, and innovate faster by leveraging cloud technologies.
What is a VNC?
VNC (Virtual Network Computing) is a graphical desktop-sharing system that allows remote control of a computer over a network. It operates by transmitting the keyboard and mouse events from one computer to another, and relaying the graphical screen updates back in the other direction.
Key features of VNC include:
- Remote Access: Users can access and control a remote computer from anywhere.
- Cross-Platform Compatibility: VNC clients and servers are available for various operating systems, including Windows, macOS, and Linux.
- Security: VNC can be secured using encryption and authentication methods to protect the connection.
Common uses of VNC include remote technical support, accessing files and applications on a remote machine, and managing servers.
Introduction
SSH-ing into OCI (Oracle Cloud Infrastructure) servers is a breeze. Simply download the private key file, and load it into your favorite SSH client software. Boom! You’re in and off you go!
But what if your application needs… GUI
Personally having a difficult time running GUI applications on my Free-Tier server, I found that a VNC connection would be necessary. After looking online for tutorials or general help, I quickly realized there was no straight answer. People said things that contradicted one another, and none of their ideas worked. In the end, I figured it out. I write this in hopes of helping those few people like me struggling with similar problems.
Supplies
- You will need a running OCI server instance (Linux in this case (e.g. Ubuntu))
- A working SSH connection to set up the VNC software and perform necessary installs.
- A VNC viewer for testing and eventually establishing connection when appropriate.
- This tutorial…๐
Connecting to Your Server Via SSH
If you have not already established a connection with your server, now is the time to do so! If you already have, skip to the next step.
Using your favorite SSH client software (I will be using PuTTY for Windows) enter the IP address and upload the proper authentication credentials (Private key file)
If you are using PuTTY, you will need to use the built-in PuTTYgen software that comes with PuTTY during install. The .key file provided by OCI does not work by default in PuTTY. Using PuTTYgen, you can convert it.
Open PuTTYgen and load the .key file provided by OCI during the server instance creation.
Follow the pop-up when it appears.
Click Save private key button to save it to your computer. This will now work in PuTTY.
Now, open the main PuTTY software and load the private key. This can be done by navigating through the tree menu in PuTTY to: Connection > SSH >Auth > Credentials
Once the file is loaded, be sure the correct IP address is saved (in the main session tab)
Save the PuTTY config with a name if desired.
Press Open to initialize the connection to the server…
If a message appears warning you about how the key is not in the cache, ignore it and click Accept connection.
Install the VNC Server
Once connected to your server via SSH, we can start running commands to install the VNC server.
Run the following command to update and upgrade your system packages/ dependencies. (This step IS important!)
sudo apt-get update && sudo apt-get upgrade
Install the VNC server and lightweight display manager. We will use TightVNC here as it is lightweight and easy to use.
sudo apt-get install lxde-core lxterminal tightvncserver
Set up the VNC server password by running: (Type “n” if it asks if you want a view-only password)
vncserver
End that VNC instance, as we need to configure it a bit more:
vncserver -kill :1
Set Up VNC Startup Script
Copy the existing startup command as a backup just in case:
mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
Create a new startup scrpt: (This is the one that will be actually used):
nano ~/.vnc/xstartup
Add the following lines to the file and save it (Save it by pressing CTRL+X, y, Enter) [Don’t forget the shebang too!]
#!/bin/bash
xrdb $HOME/.Xresources
startlxde &
Make the script executable:
chmod +x ~/.vnc/xstartup
Configure Oracle Ingress Rules (VCN)
In order for the VCN (not to be confused with VNC lol ๐) to allow external connections on port 5901 (default VNC port) you will need to configure it appropriately. This can be tricky so follow this Step-By-Step to ensure proper configuration!
Log into the Oracle Cloud dashboard and navigate to the Virtual cloud networks (VCN) page.
Click the main VCN link. For example vcn-20240307-2120
Click the main subnet link. For example subnet-20240307-2120
Click the Default Security List link. For example Default Security List for vcn-20240307-2120
And finally you are at the Ingress Rules page of your VCN! Click the “Add Ingress Rules” button
And follow the configuration specified below. (This is very important!)
- Stateless: Checked
- Source Type: CIDR
- Source CIDR: 0.0.0.0/0
- IP Protocol: TCP
- Source port range: (leave-blank)
- Destination Port Range: 5901
- Description: VNC_SETUP
Now, if done correctly, you should have an ingress rule that looks something like the following:
Here are the official Oracle Cloud docs on a related topic.
Configure Ubuntu Firewall
Once you have finished setting up the Ingress Rules, jump back to the SSH window to execute a couple more commands on you server to get it working with the VNC setup.
Run the following commands in your terminal (via SSH) to let the Ubuntu iptables know that port 5901 should allow traffic:
sudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport 5901 -j ACCEPT
sudo netfilter-persistent save
Here are the official Oracle Cloud docs on a related topic.
Start VNC Server and Connect!
Great! You’ve done it! ๐ฅณ๐ All you need to do now is start up the server and connect.
In the SSH terminal, type:
vncserver
or for additional configuration use this variation: (This example is suitable for limited-resource servers)
vncserver :1 -geometry 1024x768 -depth 16
Now, open up a VNC viewer/ client on your local machine (I used RealVNC, a popular choice) and enter the Server’s IP address in the top bar.
Hit enter, and the connection should be starting. If you see warnings about encryption, press Continue.
When prompted to enter your password, it is the same one you entered back in step 2. It is NOT the same one as your server password (unless you made them the same…)
You should now see your Server’s Desktop! Congratulations! You’ve done it! ๐ฅณ๐๐๐๐
If you encounter any issues, please leave a comment below! Thanks!