How To Install VNC Server on Ubuntu 18.04 LTS

Install VNC Server on Ubuntu 18

VNC (Virtual Network Computing) server is a free and open source software which is designed for allowing remote access to the Desktop Environment of the server to the VNC Client whereas VNC viewer is used on remote computer to connect to the server .

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation VNC Server on an Ubuntu 18.04 Bionic Beaver server.

Install VNC Server on Ubuntu 18.04 LTS Bionic Beaver

Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

sudo apt-get update
sudo apt-get upgrade
[php]

<strong> Step 2. Installing VNC Server on Ubuntu 18.04 LTS.</strong>

First, type the following command to install Xfce on your server:
[php]
sudo apt install xfce4 xfce4-goodies xorg dbus-x11 x11-xserver-utils

Next, install TigerVNC on your Ubuntu server:

sudo apt install tigervnc-standalone-server tigervnc-common

Once installed the next step is to run the vncserver command which will create the initial configuration and set up the password:

vncserver

Result:

You will require a password to access your desktops.

Password:
Verify:
Would you like to enter a view-only password (y/n)? n
/usr/bin/xauth:  file /home/chedelics/.Xauthority does not exist

New 'server2.wpcademy.com:1 (chedelics)' desktop at :1 on machine server2.wpcademy.com
Starting applications specified in /etc/X11/Xvnc-session
Log file is /home/chedelics/.vnc/server2.wpcademy.com:1.log

Use xtigervncviewer -SecurityTypes VncAuth -passwd /home/chedelics/.vnc/passwd :1 to connect to the VNC server.

After VNC Server started and created some of it’s files. We are now can turn it off to modify the xstartup file (startup script) to make it start with xfce4:

vncserver -kill :1
[php]

<strong> Step 3. Configuring VNC Server. </strong>

First, create the following file:
[php]
~/.vnc/xstartup

Add following files:

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

Next, Run the following command to make sure permissions are correct:

chmod u+x ~/.vnc/xstartup

Step 4. Creating a Systemd unit file.

The next step is to create VNC Server statup script:

/etc/systemd/system/[email protected]

Add following files:

[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=simple
User=chedelics
PAMName=login
PIDFile=/home/%u/.vnc/%H%i.pid
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill :%i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver :%i -geometry 1440x900 -alwaysshared -fg
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target

The next step is to enable the unit file with the following command:

sudo systemctl daemon-reload
sudo systemctl enable [email protected]
sudo systemctl start [email protected]

Step 4. Connecting to VNC server.

To access remote desktop on vnc server from windows system, you must have vnc viewer installed on your system. There are various vnc viewer available to use. Download any one and install on your system, for example:

TightVNC
RealVNC
TigerVNC

tightvnc-connection

Congratulation’s! You have successfully installed VNC Server. Thanks for using this tutorial for installing VNC Server on your Ubuntu 18.04 LTS Bionic Beaver. For additional help or useful information, we recommend you to check the official VNC web site.

How To Install VNC Server on CentOS 6

Install VNC Server on CentOS 6

VNC (Virtual Network Computing) server is a free and open source software which is designed for allowing remote access to the Desktop Environment of the server to the VNC Client whereas  VNC viewer is used on remote computer to connect to the server. To use VNC you must have TCP/IP connection and VNC viewer client to connect to a computer running VNC server component. The server transmits a duplicate display of a remote computer to the viewer.

This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple. I will show you through the step by step installation VNC server on CentOS 6.

Step 1. First, you need to update the system to ensure that we have all of the latest software installed.

 yum update

Step 2. Install required packages.

yum groupinstall Desktop
yum install tigervnc-server
yum install xorg-x11-fonts-Type1
yum install vnc

Step 3. Enabling VNC Server service.

service vncserver start
chkconfig vncserver on

Step 4. Create VNC password for user.

 vncpasswd

Step 5. Configure VNC server.

 nano /etc/sysconfig/vncservers

Add the following to the end of the file:

VNCSERVERS="1:wpcademy"
VNCSERVERARGS[1]="-geometry 1024x600"

Step 6. Configure firewall rules to allow the VNC connection.

iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 5801  -j ACCEPT
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 5901  -j ACCEPT
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 6001  -j ACCEPT
service iptables save
service iptables restart

Step 7. Setting Gnome session VNC.

Restart VNC service.

 service vncserver restart

Now kill the VNC Server:

 vncserver -kill :1

Edit the xstartup file in .vnc directory:

 nano .vnc/xstartup

Comment the last line and run the Gnome:

#twm & 
exec gnome-session &

Restart the service:

 service vncserver restart

Step 8.
Now go to your Windows or Linux machine and download VNC Viewer client and install in your system to access the desktop. Now you can able to connect VNC server using IP and Port ( Eg : 192.168.1.10:1) and you will be asked to enter the password, enter the password that you have created earlier.

install-vnc-server-centos6

vnc-remote-desktop-client

Congratulation’s! You have successfully installed VNC server. Thanks for using this tutorial for installing VNC server on CentOS 6 system.

You Might Also Like: How To Install VNC Server on CentOS 7

How To Install VNC Server on CentOS 7

Install VNC Server on CentOS 7

VNC (Virtual Network Computing) server is a free and open source software which is designed for allowing remote access to the Desktop Environment of the server to the VNC Client whereas  VNC viewer is used on remote computer to connect to the server .

This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple. I will show you through the step by step installation VNC server on CentOS 7.

Step 1. First, you need to update the system to ensure that we have all of the latest software installed.

 yum update


Step 2. Install Gnome desktop.

 yum groupinstall "GNOME Desktop"

Step 3. Install tigervnc server and X11 fonts.

 yum install tigervnc-server xorg-x11-fonts-Type1

Copy the VNC server configuration file to /etc/systemd/system/ for configuring the system service. While copying, you can mention which port it should listen. By default VNC server listens on 5900:

 cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:5.service

Edit VNC server file configuration:

 nano /etc/systemd/system/vncserver@:5.service
## Replace <USER> with your real user, in my case i replaced with user called “wpcademy” with the screen size ##
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’
ExecStart=/sbin/runuser -l wpcademy-c “/usr/bin/vncserver %i -geometry 1280×1024″
PIDFile=/home/wpcademy/.vnc/%H%i.pid
ExecStop=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'[Install]
WantedBy=multi-user.target

Step 4. Configure firewall rules to allow the VNC connection.

firewall-cmd --permanent --zone=public --add-port=5905/tcp
firewall-cmd --reload

Step 5. Start VNC server.

 vncserver

Set the password.

You will require a password to access your desktops.

Password:
Verify:
xauth:  file /home/wpcademy/.Xauthority does not exist

New ‘localhost.localdomain:1 (wpcademy)’ desktop is server.wpcademy.net:1

Creating default startup script /home/wpcademy/.vnc/xstartup
Starting applications specified in /home/wpcademy/.vnc/xstartup
Log file is /home/wpcademy/.vnc/server.wpcademy.net:1.log

Step 6. Enabling and starting the VNC service

Reload the systemctl daemon as root.

 systemctl daemon-reload

Start the VNC service as root:

 systemctl start vncserver@:5.service

Enable it on system startup as root:

 systemctl enable vncserver@:5.service

Step 7. Now you can able to connect VNC server using IP and Port ( Eg : 192.168.2.109:5 ) and you will be asked to enter the password, enter the password that you have created earlier.

vnc server authentication

CentOS-7-VNC-Desktop

Congratulation’s! You have successfully installed VNC server. Thanks for using this tutorial for installing VNC server on CentOS 7 system.

You Might Also Like: How To Install VNC Server on CentOS 6