Skip to content

Instantly share code, notes, and snippets.

@boubkhaled
Last active November 25, 2020 14:28
Show Gist options
  • Save boubkhaled/161b21b2b233273c0d8e2959c0e4813c to your computer and use it in GitHub Desktop.
Save boubkhaled/161b21b2b233273c0d8e2959c0e4813c to your computer and use it in GitHub Desktop.
Install tightvnc on ubuntu

source

Step 1

Start by opening a terminal and entering the following command to install TightVNC server and the XFCE desktop manager core files:

$ sudo apt install tightvncserver XFCE4 XFCE4-goodies

Step 2

After the packages are done installing, we need to configure a username and password that will be used to connect to the VNC server by a client. Create a password with this command:

$ vncpasswd

Step 3

Next, let's configure VNC to start the XFCE desktop environment when a client connects. Use nano or the text editor of your preference (ex. Atom, Sublime) to create the following file:

$ nano ~/.vnc/xstartup

Step 4

Insert the following few lines and then save your changes and exit the file:

#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
startxfce4 &

Step 5

With those changes made, edit the permissions of the file to make it executable:

$ chmod +x ~/.vnc/xstartup

Step 6 : Start VNC server

VNC runs as a service on your system. In order for clients to connect, the VNC server must obviously be running and listening for incoming connection attempts. With our configuration complete, we are ready to start VNC server with the following command:

$ vncserver

Check Port

VNC will use a new port for every remote desktop that is created. At this point, your system should be listening on port 5901 for incoming VNC connections. You can see this for yourself with the ss -ltn command:

$ ss -ltn

Add firewall rule

If you have the UFW firewall enabled, you'll need to open port 5901 so it doesn't block incoming VNC connections:

$ sudo ufw allow from any to any port 5901 proto tcp

Bonnus

You have to specify the port number (5901) when connecting with a vnc client : 192.168.1.40:5901

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment