admin/ April 14, 2016/ Linux/ 1 comments

Here I am going to show you that how to install vnc server and configure it.
We use VNC package to Remote Graphical Access. I will tell you the configuration of VNC for Linux on
Ubuntu Platform.

There are the 4 easy steps to install and configure the VNC.

On Server
Step 1-:
Install the required x11vnc package in ubuntu.

 $ sudo apt-get install -y x11vnc

For Headless server ( Server Edition) install the below packages.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install gnome-core
sudo apt-get install -y ubuntu-desktop

Note-: Please allow the port 5900 in AWS Security Group for EC2 instance.

Step 2-:
Create a password for a user.

 $ x11vnc -storepasswd

Output-:

Enter VNC Password:
Verify password:
Write password to /home/user/.vnc/passwd? [y]/n y
Password written to: /home/user/.vnc/passwd

Step 3-:

Setup Startup on Boot

Finally setup the auto start of x11vnc server on system boot. Create a x11vnc.conf file under /etc/init/ directory using following content.

$ sudo nano /etc/init/x11vnc.conf
# description "Start x11vnc on system boot"

description "x11vnc"

start on runlevel [2345]
stop on runlevel [^2345]

console log

respawn
respawn limit 20 5

exec /usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/rahul/.vnc/passwd -rfbport 5900 -shared

To run the vnc server on every start automatically. We have to open /etc/rc.local file.

 $ sudo nano /etc/rc.local

Copy the below line to start vnc session automatically with system startup, paste it the line before the “exit 0”.

 sudo x11vnc -xkb -noxrecord -forever -noxfixes -noxdamage -display :0 -auth /var/run/lightdm/root/:0 -usepw &

Output sample file of rc.local file.

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
sudo x11vnc -xkb -noxrecord -forever -noxfixes -noxdamage -display :0 -auth /var/run/lightdm/root/:0 -usepw &
exit 0

Note-: Restart the system to check it run automatically.

On Client System

Step 4-:
Now open the “Remmina Remote Desktop Client” application in your system.
Click on the Menu “Connection” -> “New”
vnc

Fill the above Form.
And connect it.

Enjoy the VNC Remote Session.

Gotechnies Linux Blog


Rating: 4.9
Votes: 480
Reviews: 560

1 Comment

  1. Hello! Could you elaborate a bit on rc.local part? Why is it different from init.d conf for example?
    I’m asking because /etc/inin.d/x11vnc start works great, but after reboot I’ve got vnc server runnning, but not accepting any connection. My guess that the differences between x11vnc.conf and rc.local are playing their role.

    To be fair I don’t understand at all why do we need modifications in rc.local at all. init.d system itself could run scripts automatically on boot, so why?

Leave a Reply