Hello and welcome to my tutorial. Here is how you can install VNC and connect to your servers.
Start by updating your packages:
sudo apt-get update
Start by installing VNC4SERVER package:
sudo apt -y install vnc4server
Now you must install your desktop enviroment. I prefer XFCE since it’s easy to setup.
sudo apt install xfce4 xfce4-goodies
Configure VNC: Run this command and enter your password for VNC!
Start your VNC service:
Kill your VNC service:
vncserver -kill :1
Before you modify the
xstartup file, back up the original:
- mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
Now create a new
xstartup file and open it in your text editor:
- nano ~/.vnc/xstartup
Commands in this file are executed automatically whenever you start or restart the VNC server. We need VNC to start our desktop environment if it’s not already started. Add these commands to the file:
#!/bin/bash xrdb $HOME/.Xresources startxfce4 &
The first command in the file,
xrdb $HOME/.Xresources, tells VNC’s GUI framework to read the server user’s
.Xresources is where a user can make changes to certain settings of the graphical desktop, like terminal colors, cursor themes, and font rendering. The second command tells the server to launch Xfce, which is where you will find all of the graphical software that you need to comfortably manage your server.
To ensure that the VNC server will be able to use this new startup file properly, we’ll need to make it executable.
sudo chmod +x ~/.vnc/xstartup
Now, restart the VNC server.
You’ll see output similar to this
New 'X' desktop is your_hostname:1 Starting applications specified in /home/sammy/.vnc/xstartup Log file is /home/sammy/.vnc/your_hostname:1.log
With the configuration in place, let’s connect to the server from our local machine.
Now at last connect with your public ip and password you provided