How To Configure VNC Server On Linux
I had a Linux box (RHEL 5.4 X64) to which I only had Telnet & SSH access. And I wanted a full screen export to test some GUI. So here is what I learnt and did to enable VNC and get a full screen export to the GNOME environment.
Make sure you have installed a VNC server on the box. You could download TightVNC source and compile it on your Linux box.
- First login to the machine as root (via telnet/SSH).
- Edit the following file
/etc/sysconfig/vncserversand add lines with the following syntax/format
VNCSERVERS=”n:username”
VNCSERVERARGS[n]=”arguments here”
For example to enable a VNC access for root user on display 2, you would enter the following lines
VNCSERVERS=”2:root”
VNCSERVERARGS[2]=”-geometry 800×600″
The above entries will enable root user to login to VNC display 2, with a screen resolution of 800 x 600.
As root run the command /usr/bin/vncpasswd; Enter and confirm the VNC login password to be used by the client. Then Edit the /etc/X11/xorg.conf and add the following lines to the end of the file –
Section “Module”
Load “glx”
Load “dbe”
Load “extmod”
Load “freetype”
Load “type1”
Load “dri”
Load “vnc”
EndSection
NOTE: Press Enter after “EndSection” then save & quit the file.
If the firewall on Linux (iptables) is enabled and running then it is likely that the ports that VNC uses (5900 – 590x) are blocked. Open those ports by running “system-config-securitylevel” at the root prompt (#). In the (curses type) CUI that appears on the screen, click on “Customize” button and in the “Allow incoming” section in the “Other ports” textfield, add “5900-5904:tcp”. Save and exit the application. You will then have to enable VNCServer for a particular run-level. And here is how you can check and enable them chkconfig –list vncserver # This list the displays enabled/disabled status (from run-level 0 to 6).
chkconfig –level 3 vncserver on
Now start the VNC service by typing “service vncserver start“. This should start the VNC server on your machine on display 2 for root user. At this point you can VNC to the server, but you will by default get a TWM window manager (which just has a X-Windows bash prompt). Which is not good enough. So to enable GNOME or KDE, Now edit the file $HOME/.vnc/xstartup, Un-comment the following lines –
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
At the end of the file, replace “twm &” with “startx &” for GNOME and “startkde &” for KDE.
Re-start your VNC service with "service vncserver restart".
With this you are all set. You can install a Tight VNC client on your Windows or any other box and then connect to display 2, by typing your machines IP followed by :2. For example – 192.168.3.130:2
Thanks to these links from where I gathered the above info 🙂
- http://www.skullbox.net/vncserver.php
- http://www.linuxquestions.org/questions/linux-newbie-8/vnc-server-no-displays-configured-629501/