Connect to VNC server using noVNC

Connect ctrlX CORE to a VNC Server using noVNC (MobaXterm)

sanX
New Contributor

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. 

Raspberry Pi and ctrlX CORE communication using TightVNC and noVNCRaspberry Pi and ctrlX CORE communication using TightVNC and noVNC

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.

Communication scheme between noVNC, VNC server and WebsockifyCommunication scheme between noVNC, VNC server and Websockify

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 

TightVNC installationTightVNC installation

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

TightVNC configurationTightVNC configuration

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

TightVNC Server statusTightVNC Server status

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

TightVNC server personalizationTightVNC server personalization

  • Save the configuration, reboot the device and check that now the VNC server 1 has the previously configured resolution and depth:

VNC server status checkVNC server status check

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:
  1. Go to Settings
  2. Access the Apps interface
  3. Change from Operating to Service mode to be able to install apps
  4. Press over "Install from file"
  5. Select the downloaded file
  6. Open it and install the noVNC app

noVNC Snap installation in ctrlX COREnoVNC Snap installation in ctrlX CORE

Step 3: Install MobaXterm

MobaXterm interfaceMobaXterm interface

Step 4: Configure MobaXterm to access per SSH to the ctrlX CORE
  1. Open MobaXterm and press over "Session"
  2. In the new window, select "SSH"
  3. Write the ctrlX CORE IP address
  4. Press "Ok" to establish the connection

ctrlX CORE SSH connectionctrlX CORE SSH connection

  • Enter the root username and password, and the following window shuld be visible:

MobaXterm interfaceMobaXterm interface

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

Port check in LinuxPort check in Linux

  • When the command is executed, noVNC generates a link where it is possible to access the noVNC interface

noVNC Start from MobaXtermnoVNC Start from MobaXterm

  • Open a web browser, enter the generated link and press over the "Connect" button

noVNC startnoVNC start

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

noVNC IP address troubleshootingnoVNC IP address troubleshooting

  • 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

noVNC ConfigurationnoVNC Configuration

  • Enter the credentials and press "Send credentials"

Credentials introductionCredentials introduction

  • The device's desktop environment will be visible

Raspberry Pi desktop shared to noVNCRaspberry Pi desktop shared to noVNC

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

  1. The command is written
  2. All the information is written
  3. The certificate file is generated in the /home/user folder

Security certificate generationSecurity certificate generation

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

noVNC with certificate commandnoVNC with certificate command

  • Now, when noVNC is running, SSL/TSL support wll appear active

SSL/TLS Support checkSSL/TLS Support check

JosX
JosX
Hi, I'm Josef from DCEM (Applikation Deutschland Österreich Schweiz). Feel free to contact me.
Editorial work by: sanX
2 Comments
Must Read
Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist