Introduction
VNC Viewer Linux, is a secure network connection system that can allow you to use the keyboard and mouse to interact with graphical desktop computers on a remote server. It can manage files, software, and settings to the server much easier for users who are not proficient with the command line. In this guide module, you will set up a VNC server on an Ubuntu 18.04 server and connect it securely via the SSH path. You will use TightVNC, a fast and safe remote control package.
Prerequisites for Completing this Tutorial, You Must:
Prepare one Ubuntu 18.04 server by following Ubuntu 18.04's initial server setup guidelines, including sudo non-root users and firewalls. Local computer with an installed VNC client that supports VNC connections via the SSH path. In Windows, you can use TightVNC, RealVNC, UltraVNC.
On MacOS, you can use the default Screen Sharing program, or you can use cross-platform applications like RealVNC. Linux, you can choose from several options, including vinagre, krdc, RealVNC, or TightVNC.
![]() | VNC Viewer Linux Free Driver |
Step 1 - Install the VNCViewer Application and VNC Server
By default, the Ubuntu 18.04 server does not come with the graphical desktop environment or the VNC server installed, so we will start by installing it. In particular, we will install packages for the latest Xfce desktop environment and the TightVNC package available in the official Ubuntu repository.
On your server, update your package list:
- sudo apt update
- Now install on the Xfce desktop computer on your server:
- sudo apt install xfce4 xfce4-goodies
- After the installation is complete, install the TightVNC server:
- sudo to install tightvncserver
To complete the initial configuration of the VNC server after it is installed, use the vncserver command to set a secure password and create the initial configuration file:
vncserver
You will be asked to enter and verify your password to access your machine remotely:
Output
You will need a password to access your desktop.
Password:
Check:
Password length must be between six and eight characters. Passwords of more than 8 characters will be truncated automatically. After verifying the password, you will be asked to make an option to create a password only-see. Users who enter with just-see passwords will not be able to control VNC instances with their mouse or keyboard. This is a useful option if you want to show someone else using your VNC server, but this is not required.
This process then creates the required default configuration file and connection information for the server:
Output
Do you want to enter just-see password (y / n)? n
xauth: file /home/sammy/.Xauthority does not exist
The new 'X' desktop is your_hostname: 1
Create a default / home / sammy / .vnc / xstartup startup script
Start the application specified in /home/sammy/.vnc/xstartup
The log file is /home/sammy/.vnc/your_hostname:1.log
Now let's configure the VNC server.
Step 2 - Configure the VNC Server
The VNC server must know which commands to run when running. In particular, VNC must know which graphics desktop to connect. This command is located in a configuration file called xstartup in the .vnc folder under your home directory. The startup script is done when you run vncserver in the previous step, but we have to make it ourselves to launch the Xfce desktop.
When VNC is first set, it launches the default server instance on port 5901. This port is called the display port, and is called by VNC as: 1. VNC can launch several instances on other display ports, such as: 2,: 3, and so on.
Because we will change the way the VNC server is set up, we first stop the VNC server instance that is running on port 5901 with the following command:
vncserver -kill: 1
The output will look like this, even though you will see different PIDs:
Output
Kill the Xtightvnc ID 17648 process
Before you edit the xstartup file, save the original:
mv~/.vnc/xstartup~/.vnc/xstartup.bak
Create a new xstartup file and open it in your text editor:
nano ~ / .vnc / xstartup
The commands in this file are run automatically every time you start or restart the VNC server. We need VNC to start our desktop environment if it hasn't started yet. Add this command to file:
~ / .vnc / xstartup
#! / bin / bash
xrdb $ HOME / .Xresources
startxfce4 &
The first command in the file, xrdb $ HOME / .Xresources, tells the VNC GUI framework to read the server user .Xresources file. .Xresources is where users can make changes to certain settings of the desktop graphics, such as terminal colors, cursor themes, and font rendering. The second command tells the server to launch Xfce, where you will find all the graphics software you need to safely manage your server.
To ensure that the VNC server can use this new startup file correctly, we must make it executable.
sudo chmod+x~/.vnc/xstartup
Now, restart the VNC server.
vncserver
You will see an output similar to this:
Output
The new 'X' desktop is your_hostname: 1
Start the application specified in /home/sammy/.vnc/xstartup
The log file is /home/sammy/.vnc/your_hostname:1.log
With the configuration in place, let's connect to the server from our local computer.
Discussion: