Introduction
In this article, it will be shown how to connect a ctrlX CORE with a VNC server using noVNC. To achieve this, the TightVNC server will be used. VNC(Virtual Network Computing) is a communication system that allows to remotely access from another device being able to control and see the dektop environment of the device that is sharing. The VNC server will be configured in the device that shares the desktop (Raspberry Pi in this case) and the VNC client will be configured from another device (ctrlX CORE in this case) or even it is possible to use it in the same device.
On the other hand, noVNC is a HTML client which allows to connect to a VNC server from a browser. As noVNC is a HTML file along with several JavaScript and CSS files, it is required to launch them with a program. This program is called Websockify and it basically creates the noVNC website. Additionally, it also helps noVNC to communicate with the VNC server as noVNC only understands WebSocket. WebSocket is a communication protocol which allows to establish a bidirectional communication between client and server. Comparing it to HTTP where it is only unidirectional and the communication is closed after each request, WebSocket allows to have unlimited number of requests and responses. This persistent data stream make this communication a much faster option compared to HTTP.
Prerequisites
- VNC server (In this case, TightVNC will be used)
- ctrlX CORE with Root user
- noVNC App
- MobaXterm
VNC server configuration
In this section it will be shown how to configure the VNC server. These steps can be followed on any Linux device and it is not required to have a Raspberry Pi. The VNC server will provide a desktop environment for the device that will connect remotely.
Step 1: Install VNC Server
- Connect the device to Internet and check if there are system updates:
sudo apt-get update && apt-get upgrade
- Install TightVNC
sudo apt-get install tightvncserver
Step 2: Configure TightVNC
- Configure password:
/usr/bin/tightvncserver
Now it will be shown how to configure TightVNC so that is automatically starts when booting the system.
- Open a terminal window and enter:
sudo nano /etc/systemd/system/tightvncserver.service
- Write or copy the following lines:
[Unit]
Description=TightVNC remote desktop server
After=sshd.service
[Service]
Type=dbusExecStart=/usr/bin/tightvncserver :1
User= Enter your username
Type=forking
[Install]
WantedBy=multi-user.target
Note: To save the configuration, press "ctrl" + "O" --> Press "Enter" --> Press "ctrl" + "X" to return back to the terminal
- Change the file so that it is owned by root:
sudo chown root:root /etc/systemd/system/tightvncserver.service
- Make the file executable by running:
sudo chmod 755 /etc/systemd/system/tightvncserver.service
- Reboot the device and check that the script works by running:
sudo systemctl start tightvncserver.service
- Enable startup at boot using:
sudo systemctl enable tightvncserver.service
Restart again and check that it has automatically started by running the command:
sudo systemctl status tightvncserver.service
Step 3: Perform additional configurations
- With this command it is possible to configure resolution and depth for a VNC Server 2
vncserver :2 -geometry 1920x1080 -depth 16
Note 1: Now there will be a VNC server in the port 5901 with the default configuration and another VNC server in the port 5902 with the previously shown configuration
Note 2: This configuration can also be included in the default file that was previously configured
- Open the terminal, write the command, and change was is shown in the following image:
sudo nano /etc/systemd/system/tightvncserver.service
- Save the configuration, reboot the device and check that now the VNC server 1 has the previously configured resolution and depth:
ctrlX CORE configuration
Step 1: Connect ctrlX CORE with Raspberry Pi
- First, it is required to connect the Raspberry Pi and the ctrlX CORE as shown in the first image of this article. To configure the IP address, please follow the steps shown in this tutorial.
Step 2: Install noVNC
- Download the file provided in this article and access the ctrlX CORE web interface
- To access the ctrlX CORE web interface check the Quick Start Guide
- To install the file provided in this article, check the tutorial or follow the steps:
- Go to Settings
- Access the Apps interface
- Change from Operating to Service mode to be able to install apps
- Press over "Install from file"
- Select the downloaded file
- Open it and install the noVNC app
Step 3: Install MobaXterm
- Download the Windows program in the official webpage and install it
Step 4: Configure MobaXterm to access per SSH to the ctrlX CORE
- Open MobaXterm and press over "Session"
- In the new window, select "SSH"
- Write the ctrlX CORE IP address
- Press "Ok" to establish the connection
- Enter the root username and password, and the following window shuld be visible:
Step 5: Configure and start noVNC
- Execute the command shown below.
After --vnc write the VNC Server device IP address (In this case the Raspberry Pi) and the assigned port by the server
novnc --listen 6081 --vnc 180.254.3.2:5901
Note: Make sure to write the correct port where the VNC server is configured. To check the assigned ports, open a terminal in the Raspberry Pi and write:
netstat -tulpn
- When the command is executed, noVNC generates a link where it is possible to access the noVNC interface
- Open a web browser, enter the generated link and press over the "Connect" button
Note: In the case it does not work with the link, in the same link address, change the ctrlx-core part with the ctrlX CORE IP address
- On the other hand, it is also required to access the noVNC settings and enter the ctrlX CORE IP address before pressing the "Connect" button
- Enter the credentials and press "Send credentials"
- The device's desktop environment will be visible
Generate certificate to increase VNC connection security
Step 1: Generate certificate using MobaXterm
- Write the the following command in MobaXterm:
sudo openssl req -x509 -nodes -newkey rsa:2048 -keyout novnc.pem -out novnc.pem -days 365
Note: The file name can be defined as desired. In this case the name will be novnc
- The command is written
- All the information is written
- The certificate file is generated in the /home/user folder
Step 2: Test the VNC connection with the generated certificate file
- When running the noVNC command it is required to add the certificate file as shown below:
novnc --listen 8443 --cert novnc.pem --vnc 180.254.3.2:5902
- Now, when noVNC is running, SSL/TSL support wll appear active