Wondering how to install VNC on your Ubuntu system?
Virtual Network Computing or VNC is a cross-platform sharing technology that allows users to access their computers remotely.
Using VNC, users can even control their mouse, keyboard, and other peripheral devices remotely, thus creating a virtual environment such that they are sitting right in front of their system.
The VNC technology is quite gripping and inspiring. It enables the wide range of a computer’s abilities to be used in new and innovative ways.
VNC works on the server-client model. The VNC server is installed on the computer, which will be controlled, and the VNC viewer or client is installed on the controlling device. The controlling device can be either a computer or any smart mobile phone and tablet.
Once setup is done, the server sends a copy of the desktop environment to the client device.
VNC is available for multiple platforms, including Linux and its various distros. Installing and configuring VNC on your system can be a bit tricky, so if you want to know how to install VNC on Ubuntu without any hindrances, you’ve come to the right place.
So let’s get started!
Step 1: Install a Desktop Environment.
The first thing that you need to do is to install a desktop environment. Desktop environments are applications that give you an alternative to the default desktops provided by your operating systems.
Considering that VNC operates on the server-client model, the quality of your experience using VNC depends on -among other things- the rate of data transfer. So, using lightweight desktop environments is the better option.
There are multiple environments available for Ubuntu. It’s on you which environment you want to install and use. We will be installing the Xfce desktop environment application for our Ubuntu. You can follow these steps to install an environment of your choice.
- Start by opening the Terminal application.
- Once opened, type the following command to update your repositories and get the latest package information:
$ sudo apt-get update
- After updating, it is time to install the Gnome application. Type the following command:
$ sudo apt install xfce4 xfce4-goodies
Press ‘Y’ to grant permission and start the installation process.
- After installing, restart your system to see the new desktop environment.
These are the steps you can follow to install different desktop environments. In case there is no repository package for your preferred environment, use your web browser to install the package and run the setup.
Step 2: Install and Configure TightVNC Server.
The next step of how to install VNC on Ubuntu is to install the VNC server and configure it on your main computer. Follow these steps to install it and properly configure it.
- First, open the Terminal.
- Type in the following command to install the TightVNC application.
$ sudo apt install tightvncserver
- After installing, run the following command to perform the initial configuration and set up an access password.
You’d have to enter a password first. After verifying the password, you will have the option to create a view-only password. The view-only password will allow users to see just the desktop, but they can’t use the keyboard or mouse.
- You can always change your passwords using this command.
You need to configure the VNC server to operate using your preferred desktop environment. The commands that VNC runs at startup are located in the “xstartup.vnc” folder. You will be making changes to this file to create a backup for it using the following command.
$ mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
- Now, kill the VNC server process by typing the following:
$ vncserver -kill :1
- Next step is to open the “xstartup” file using the nano text editor.
$ nano ~/.vnc/xstartup
- In nano, the following lines are to be added:
Secure your changes by saving and closing the file.
- The next step is to make sure that this file will be executed upon startup. Do this using the following command.
$ chmod +x ~/.vnc/xstartup
Restart the server using the
$vncserver -localhost command. “-localhost” will instruct VNC to use the server on which it is installed to make connections.
Step 3: Establish an SSH Tunnel.
VNC isn’t very safe on its own. The security protocols used by VNC are weak and can be hacked into by perpetrators. You should establish an SSH tunnel between your computer and the server to prevent such things from happening.
The SSH tunnel will add a layer of security to your connection, and only those users will have access to VNC who have SSH access to your server. You need to instruct the VNC to make a connection using SSH rather than making a direct one.
This can be done by following these steps:
- Open the Terminal.
- Type in the following command:
$ ssh -L 59000:localhost:5901 -C -N -l username your_server_ip
When you execute this command, the VNC server is instructed to connect port 5901 and port 59000 on your computer using port 22, which is the default port for SSH.
Step 4: Execute VNC as a System Service.
By configuring VNC to execute as a system service, you can start, run and close it like any other system application. It is a better option rather than having VNC always boot up when your system starts.
To run VNC as a system service, follow these steps:
- Open the Terminal.
- Use this command for creating a new file:
$ sudo nano /etc/systemd/system/[email protected]
- When the nano text editor opens, add the following lines to the file:
After adding these lines, secure the changes by saving and closing the file.
- Now, type the following to let the system know that there is a new system file.
$ sudo systemctl daemon-reload
- Make the unit file executable.
$ sudo systemctl enable [email protected]
- In case VNC is running, kill it using this command:
$ vncserver -kill :1
- Now, start it using this command:
$ sudo systemctl start vncserver@1
With this, you are done with installing VNC on Ubuntu.
Another service that makes use of remote management is Webmin. Webmin is a must-have as it allows the user to remotely access and manage their web server from the comfort of their web browser.
This article was a step-by-step tutorial on how to install VNC on your Ubuntu system. We hope that we were able to cover up everything, and we helped you out in setting up VNC on your computer. If you have any questions or suggestions, let us know in the comment section down below.