Sunday, August 5, 2018

Install & Configure Tiger VNC Server on CentOS 6 or RHEL 6

VNC (Virtual Network Computing) is a technology for remote desktop sharing, a form of remote access on computer networks. VNC enables the visual desktop display of one computer to be remotely viewed and controlled over a network connection.

Remote desktop technology like VNC is useful on home computer networks, allowing someone to access their desktops from another part of the house or while traveling. It is also useful for network administrators in business environments, such as Information Technology (IT) departments who need to remotely troubleshoot employees' systems.

How VNC Works

VNC works in a client/server model and uses a specialized network protocol called Remote Frame Buffer (RFB). VNC clients (sometimes called viewers) share user input (keystrokes, plus mouse movements and clicks or touch presses) with the server. VNC servers capture the local display frame buffer contents and share them back to the client, plus take care of translating the remote client input into local input. Connections over RFB normally go to TCP port 5900 on the server.

Installation
[root@vnc ~]# yum install tigervnc-server -y
Now make the service start after every reboot
[root@vnc ~]# chkconfig vncserver on
Configuration

Lets create a user to which you will be connecting from remote desktop and then we will configure vnc for that created user.

In my case I am using user=oracle, it can differ in your case.
[root@vnc ~]# useradd oracle
Now assign the vncpassword for the user oracle:
[root@vnc ~]# su - oracle
[oracle@vnc ~]# vncpasswd 
Password:<--yourvncpassword
Verify:<--yourvncpassword
[oracle@vnc ~]#
Edit configuration file for the vncserver:
[root@vnc ~]# vi /etc/sysconfig/vncservers
[...]
VNCSERVERS="1:oracle"
VNCSERVERARGS[1]="-geometry 1920×1200"
By default, the vncserver listens on port 5901 and I've configured 1920×1200 resolution for the VNC client, you can choose the resolution of your own choice.

Now restart the VNC server:
[root@vnc ~]# service vncserver restart
Shutting down VNC server:                                  [  OK  ]
Starting VNC server: 1:oracle xauth:  creating new authority file /home/oracle/.Xauthority

New 'vnc.oracleapps.com:1 (oracle)' desktop is vnc.oracleapps.com:1

Creating default startup script /home/oracle/.vnc/xstartup
Starting applications specified in /home/oracle/.vnc/xstartup
Log file is /home/oracle/.vnc/vnc.oracleapps.com:1.log
                                                           [  OK  ]
[root@vnc ~]#
Now as oracle user open the file /home/oracle/.vnc/xstartup and comment the line #twm & add the line "exec gnome-session" as follows:
#!/bin/sh

[ -r /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
export LANG
export SYSFONT
vncconfig -iconic &
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
OS=`uname -s`
if [ $OS = 'Linux' ]; then
  case "$WINDOWMANAGER" in
    *gnome*)
      if [ -e /etc/SuSE-release ]; then
        PATH=$PATH:/opt/gnome/bin
        export PATH
      fi
      ;;
  esac
fi
if [ -x /etc/X11/xinit/xinitrc ]; then
  exec /etc/X11/xinit/xinitrc
fi
if [ -f /etc/X11/xinit/xinitrc ]; then
  exec sh /etc/X11/xinit/xinitrc
fi
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
exec gnome-session &
Finally, reboot the machine
[root@vnc ~]# init 6
or
[root@vnc ~]# reboot
VNC Client

At client end my OS is Windows with RealVNC installed on my client machine. Otherwise you can install any VNC-client of your choice.

Now connect to the VNC server using the VNC-client:

When prompted for the password, provide the same password which you set for vncserver

Now provide oracle user account password

You will be connected to the oracle user desktop.

No comments:

Post a Comment