Install VNC Server - TightVNC

From Embedded Workshop
Jump to navigation Jump to search

VNC: Virtual Network Computing
Let's follow the directions provided by Digital Ocean:
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-18-04

On your server, begin by updating your list of packages:

$ sudo apt-get update

Install the lightweight Xfce desktop environment, along with some "goodies"

$ sudo apt-get install xfce4 xfce4-goodies

Stop and check diskspace:

ubuntu@ip-172-31-26-122:~$ df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/xvda1       8065444 2330024   5719036  29% /

Once the desktop environment is in place, install the TightVNC service:

$ sudo apt-get install tightvncserver

Stop and check diskspace:

ubuntu@ip-172-31-26-122:~$ df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/xvda1       8065444 2332520   5716540  29% /

Run the following to create the password(s) and configuration files for your VNC service:
Password must be between six and eight characters in length.
Passwords longer than eight characters will be truncated.
At this time, you can also create a "View Only" password.

$ vncserver

We will now configure the VNC service, but first, we must stop the service:

$ vncserver -kill :1

We are going to be modifying the xstartup file. Before doing that, rename the original file:

$ mv ~/.vnc/xstartup ~/.vnc/xstartup.bak

Create a new xstartup file

$ sudo nano ~/.vnc/xstartup

Commands in this file are executed whenever you start or restart the VNC serice. We need VNC to start our desktop environment if it isn't already started. Add the following commands to the xstartup file:

#!/bin/sh
xrdb $HOME/.Xresources
#xsetroot -solid grey
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
startxfce4 &

Make sure the file has execute permission

$ sudo chmod +x ~/.vnc/xstartup

Now, restart the VNC service:

$ vncserver

To connect a VNC client, we need to open access to port 5901 (default port number for VNC)

Security Groups -> launch-wizard-1, click on "Inbound" tab
Click Edit
Click "Add Rule" in the Edit inbound rules dialog box
Custom TCP Rule, TCP, 5901, Anywhere 0.0.0.0/0,::/0 , VNC Port

If using the Real VNC, VNC Viewer, when entering the host name, also define the port as 5901

example:  bill.hopto.org:5901

Once everything appears to be working (more or less)... Install Chromium Web Browser

$ sudo apt install -y chromium-browser