17 Jan 2012

Connect to VNCServer on Red Hat Enterprise Linux

tightvnclogo Virtual Network Computing (VNC) is remote control software to allow computers interact with one another as a server and client. It is developed to ease the administration of remote machines without using the console. For Windows users, there may be a a familiar feel similar to that of Windows Terminal Services (RDP). VNCServer is standard on a Red Hat Enterprise Linux (RHEL) install. To connect to the VNCServer service on the RHEL box, Windows users among other builds, may use an application called TightVNC. This guide will get the VNCServer service configured so that TightVNC will be able to access the RHEL installation.
Prerequisities
  • root privledges
  • TightVNC client software
Setup VNC Server
Start the vncserver serivce, if the service is not already running. Then set a password to access the VNC desktop; this is done the first time. It may be changed at anytime with the vncpasswd command. Then activate the VNC desktop with the vncserver command. A connection may be made either with the computer name or IP address.
1[root@myrhelserver etc]# service vncserver start
2Starting VNC server: [ OK ]
3[root@myrhelserver etc]#
4[root@myrhelserver etc]# vncpasswd
5Password:
6Verify:
7[root@myrhelserver etc]#
8[root@myrhelserver etc]# vncserver
9
10New 'myrhelserver:1 (root)' desktop is myrhelserver:1
11
12Starting applications specified in /root/.vnc/xstartup
13Log file is /root/.vnc/myrhelserver:1.log
14
15[root@myrhelserver etc]#
Connect with TightVNC
This guide assumes that TightVNC is already installed.
  • Type in the VNC server name or IP and the connection number (could be 1 or in my case 2, or so on)
    tvnc02
  • After successfully connecting, the screen will most likely be greyed with a terminal screen.
To change this to a windows like GUI pending on the installation, KDE or Gnome there are a few more steps.
  • Using terminal access and logged in as root into the root directory type
    [root@myserver ~]# ls -a
  • Change to the hidden directory .vnc
    [root@myserver ~]# cd .vnc
  • Check for the existance of xstartup
    [root@myserver ~]# ls
  • If it is there, and it should be, edit the xstartup file to match this one
1#!/bin/sh
2
3# Uncomment the following two lines for normal desktop:
4unset SESSION_MANAGER
5exec /etc/X11/xinit/xinitrc
6
7[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
8[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
9xsetroot -solid grey
10vncconfig -iconic &
11xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
12startkde &
Note: The command startx will launch Gnome and the command startkde will launch the KDE desktop upon login via VNCserver.
The result
Relaunch TightVNC and access the KDE desktop of this Red Hat Enterprise Edition 5.2 installation.
tvnc03
source


Additional
Assuming in /etc/sysconfig/vncservers you have 2 displays configured, they are
running and are actively being used.  Adding a 3rd display, and typing:

# service vncserver start
Starting VNC server: 1:root A VNC server is already running as :1
                                                           [FAILED]

fails...   This is because in /etc/rc.d/init.d/vncserver:

    for display in ${VNCSERVERS}
    do
        NOSERV=
        echo -n "${display} "
        unset BASH_ENV ENV
        DISP="${display%%:*}"
        export USER="${display##*:}"
        export VNCUSERARGS="${VNCSERVERARGS[${DISP}]}"
        runuser -l ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] && vncserver
:${DISP} ${VNCUSERARGS}"
        RETVAL=$?
==>>    [ "$RETVAL" -ne 0 ] && break
    done

There is an exit from the loop upon the first error.  If you comment out that
line, the output looks more reasonable:

# service vncserver start
Starting VNC server: 1:root A VNC server is already running as :1
2:root A VNC server is already running as :2
3:root A VNC server is already running as :3
4:root 
New 'mynode:4 (root)' desktop is mynode:4

Start should follow through for all displays.

you could do restart, but that kills all currently used displays which is bad.

Tidak ada komentar:

Posting Komentar