Monday, December 28, 2009

Setting up VNC Server on Linux

Hi all,

These days it is common that DBAs are required to work on different databases located at various geographical locations. DBAs can connect to their servers using various protocols like telnet, ssh etc etc. but they are usually command line tools what if u want to work on the server in GUI mode. Heres comes VNC in this situation i m not goin into details what VNC is u can easily find info on google or wikipedia. Just basic info for this setup you are required two components VNC Server and VNC Viewer.

In this post i m going to show how to setup a VNC Server on Linux Machine and running viewer on windows.

1. Download Free VNC Server version for Linux and Viewer for Windows from http://www.realvnc.com/products/free/4.1/download.html
Note: Make sure u have downloaded VNC Free Edition for Linux RPM and VNC Free Edition Viewer for Windows

2. Log on to Linux Machine using root and create seperate user and group for VNC.

# groupadd vncuser
# useradd vncuser -g vncuser
# passwd vncuser

 3. Install the rpm package on Linux machine which will become your VNC server.

# rpm -U package-name

4. Edit the file /etc/sysconfig/vncserver and add line
VNCSERVERS="9:vncuser"


file look like this


# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the line below to start a VNC server on display :1
# as my 'myusername' (adjust this to your own).  You will also
# need to set a VNC password; run 'man vncpasswd' to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted!  For a secure way of using VNC, see
# .

# VNCSERVERS="1:myusername"
# VNCSERVERARGS[1]="-geometry 800x600"
VNCSERVERS="9:vncuser"


5. Login with vncuser account
 # su - vncuser
6. Run the following command from vncuser to start the VNC server on Linux machine
$ vncserver :9

Note: ":9 means that VNC server will listen to Port Number 5909 u can use any number depends on your settings port will always be 5900 plus"
This command will ask for password as well.

7. To verify whether VNC server is running or not run the following command

$ ps -ef | grep Xvnc

Output would be similar to this

vncuser   4193     1  0 Dec28 ?        00:08:57 Xvnc :9 -desktop server.com:9                 (vncuser) -httpd /usr/share/vnc/classes -auth /home/vncuser/.Xauthority -geometry 1024x768 -depth 16 -rfbwait 30000 -rfbauth /home/vncuser/.vnc/passwd -rfbport                 5909 -pn

8. Edit the xstartup file in $HOME/.vnc folder of vncuser'sHOME (/home/vncuser/.vnc) and uncomment the following parameters

SESSION_MANAGER
/etc/X11/xinit/xinitrc

file output would be like this

[vncuser@server .vnc]$ cat xstartup
#!/bin/sh

# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &

if everything looks good then move to the viewer setup.

7. Run the downloaded viewer file from Windows client.

9. Click Options select Full colors in Color section


10. Enter IP Address or Hostname along with VNC Server Port
VNC Server-IP-Address or VNC Server Hostname :5909
e,g 192.168.0.254:5909





11. Click OK
Note: You can change VNC password from /usr/bin/vncpasswd command as well

12.Now enjoy your session and work in viewer like as your server is in front of you :)



Any comments suggestions are welcome.

Cheers,

Baig

No comments:

Post a Comment