How To Install VNC Server On Ubuntu 14.04

How To Install VNC Server On Ubuntu 14.04 

 

Version 1.0
Last edited 11/Jun/2014

This guide explains the installation and configuration of a VNC server on Ubuntu 14.04 server. I use a server here to show you a ay to have a remote desktop on a root server in a datacenter. The same steps will work for Ubuntu desktops as well.VNC is a very convinient way of administrating the Ubuntu 14.04 desktops remotely. The GUI can be accessed from anywhere over the internet or local network with a VNC client on any OS. The only requirement is that the connecting OS has a VNC-client installed on it.

1 Preliminary Note

In my case I have a fresh installed Ubuntu14.04 server in a datacenter (root server) were I will install the VNC server so that I can access the Ubuntu Gnome GUI remotely. If you do. In case that you havent a Ubuntu minimal installation yet, follow this guide for the basic installation of the Ubuntu server till Chapter 11. All of the cases are same as per the guide. My network details are as follows:

IP address 192.168.0.100
Gateway 192.168.0.1
DNS     8.8.8.8    8.8.4.4
Hostname server1.example.com

VNC-server benefits

  • Remote GUI administration makes work easy & convenient.
  • Clipboard sharing between host Ubuntu server & VNC-client machine.
  • GUI tools can be installed on the host Ubuntu server to make the administration more powerful
  • Host Ubuntu server can be administered through any OS having the VNC-client installed.
  • More reliable and faster then running a X-Server over SSH.
  • More reliable then RDP connections.

2 Installation

I am logged in my system as  root  user on the shell (e.g. by ssh). Now I will install the VNC-server.

 apt-get install gnome-core xfce4 firefox

 apt-get install vnc4server

Please make sure that you are using only vnc-server & no other VNC-server are installed as this could give errors in future mostly that clipboard sharing between the host Ubuntu Server & vnc-client machine. You can check it as follows:

root@vboxtest ~ # dpkg -l | grep vnc
ii  vnc4server                                            4.1.1+xorg4.3.0-37ubuntu5                           amd64        Virtual network computing server software
root@vboxtest ~ #

Please uninstall if tightvnc or anything similar installed.


3 Adding VNC user

In my case I am using  user=srijan  it will differ in your case. You can use any username for the same.

adduser srijan


root@server1:~# adduser srijan
Adding user `srijan' ...
Adding new group `srijan' (1001) ...
Adding new group `srijan' (1001) ...
Adding new user `srijan' (1001) with group `srijan' ...
Creating home directory `/home/srijan' ...
Copying files from `/etc/skel' ...

Enter new UNIX password: <--yourpassword
Retype new UNIX password: <--yourpassword
passwd: password updated successfully
Changing the user information for srijan
Enter the new value, or press ENTER for the default
    Full Name []: <--ENTER
    Room Number []: 
<--ENTER 
    Work Phone []:
<--ENTER 
    Home Phone []:
<--ENTER
    Other []:
<--ENTER 
Is the information correct? [Y/n]
<--ENTER

Further we need to start the vncserver with the user, for this use:

su - srijan

vncserver

It will show this on the prompt:

srijan@server1:~$ vncserver

You will require a password to access your desktops.

Password:<--Put your VNC password 
Verify:<--Put your VNC password
Password too long - only the first 8 characters will be used
xauth:  file /home/srijan/.Xauthority does not exist

New 'server1:1 (srijan)' desktop is server1:1

Creating default startup script /home/srijan/.vnc/xstartup
Starting applications specified in /home/srijan/.vnc/xstartup
Log file is /home/srijan/.vnc/server1:1.log

srijan@server1:~$

Now I am going to make backup of the original file & then make the configuration as follows:

cp ~/.vnc/xstartup ~/.vnc/xstartup.bak
> ~/.vnc/xstartup
vi ~/.vnc/xstartup

#!/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 &

It will have some issues with the gnome-vnc session so please kill the present vnc session as follows:

vncserver -kill :1

Further I will make the startup script for the vncserver like this:

su 
vi /etc/init.d/vncserver


#!/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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值