Easy way to Setup VNC - Server Ubuntu/Debian OS

This guide is for installing VNC-Server on the servers installed with Ubuntu/Debian OS

1. Log in to the server as root

2. Run the following commands:

apt-get update

apt-get install gnome-core xfce4 firefox

apt-get install vnc4server

You need to create positive that you just ar mistreatment solely vnc-server and no alternative VNC-server installations were gift within the server as this might provide errors within the future largely that writing board sharing between the host Ubuntu Server and vnc-client machine. you'll be able to check it mistreatment the subsequent command:

root@vnctest ~ # dpkg -l | grep vnc

ii  vnc4server                                            4.2.3+xorg4.3.0-37ubuntu5                           amd64        Virtual network computing server software

root@vnctest ~ #

Please uninstall if TightVNC or any other installations there. 

3. Once the above packages are fully installed, we need to add a normal user for using VNC

useradd jack

You need to use your own username here.

Then use the following command:

su - jack

vncserver

Put a password for the vnc user there and verify the same.

4. We need to copy the original file and create a new configuration file as shown below:

cp ~/.vnc/xstartup ~/.vnc/xstartup.bak

> ~/.vnc/xstartup

vi ~/.vnc/xstartup

5. Edit the file as below:

#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
startxfce4 &
 
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &

6. There will be some issues with the gnome-vnc session so we need to kill the present vnc session as below:

# vncserver -kill :1

7. Then we need to make a startup script:

su 

vi /etc/init.d/vncserver

and paste the following:

#!/bin/bash
 
unset VNCSERVERARGS
VNCSERVERS=""
[ -f /etc/vncserver/vncservers.conf ] && . /etc/vncserver/vncservers.conf
prog=$"VNC server"
start() {
 . /lib/lsb/init-functions
 REQ_USER=$2
 echo -n $"Starting $prog: "
 ulimit -S -c 0 >/dev/null 2>&1
 RETVAL=0
 for display in ${VNCSERVERS}
 do
 export USER="${display##*:}"
 if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then
 echo -n "${display} "
 unset BASH_ENV ENV
 DISP="${display%%:*}"
 export VNCUSERARGS="${VNCSERVERARGS[${DISP}]}"
 su ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS}"
 fi
 done
}
stop() {
 . /lib/lsb/init-functions
 REQ_USER=$2
 echo -n $"Shutting down VNCServer: "
 for display in ${VNCSERVERS}
 do
 export USER="${display##*:}"
 if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then
 echo -n "${display} "
 unset BASH_ENV ENV
 export USER="${display##*:}"
 su ${USER} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1
 fi
 done
 echo -e "\n"
 echo "VNCServer Stopped"
}
case "$1" in
start)
start $@
;;
stop)
stop $@
;;
restart|reload)
stop $@
sleep 3
start $@
;;
condrestart)
if [ -f /var/lock/subsys/vncserver ]; then
stop $@
sleep 3
start $@
fi
;;
status)
status Xvnc
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 1
esac

Then we need to make it executable:

chmod +x /etc/init.d/vncserver

8. We need to create a configuration file for VNC:

mkdir -p /etc/vncserver

vi /etc/vncserver/vncservers.conf

Paste the following:

VNCSERVERS="1:jack"
VNCSERVERARGS[1]="-geometry 1024x768"

9. If you need to make it started after the reboot automatically, a startup script needed to be written on the rc.d like below:

update-rc.d vncserver defaults 99

root@server1:~# update-rc.d vncserver defaults 99
 Adding system startup for /etc/init.d/vncserver ...
   /etc/rc0.d/K99vncserver -> ../init.d/vncserver
   /etc/rc1.d/K99vncserver -> ../init.d/vncserver
   /etc/rc6.d/K99vncserver -> ../init.d/vncserver
   /etc/rc2.d/S99vncserver -> ../init.d/vncserver
   /etc/rc3.d/S99vncserver -> ../init.d/vncserver
   /etc/rc4.d/S99vncserver -> ../init.d/vncserver
   /etc/rc5.d/S99vncserver -> ../init.d/vncserver 

 10. Reboot the server. 

 

  • vnc server debian, vnc server ubuntu
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

DDOS and DNS A Records Need Why ?

It is required that all DDOS shared hosting clients use Rivalhost Global Protected Name-servers...

Can you change my PHP version?

All new shared hosting accounts are created on a server which runs php version 5.3.x or higher We...

Do you host adult sites or content?

Yes we have Offshore Server also Offshore/ anonymous location . you can host / or runs any type...

Can I have multiple domains point to the same website?

Yes. These are commonly referred to as "parked domains" and allow you to have multiple domain...

How long does it take for my account to be setup?

Generally, it will not take more than 24 hours for us to setup your account, unless we have...