Topics: Red Hat / Linux

Installing VNC server

This is a description on how to install a VNC server on a Linux system, and how to access it from a Windows desktop.

First run on the Linux server:

# yum install vnc-server twm xterm
Edit file /etc/sysconfig/vncservers, and add:
VNCSERVERS="1:user1 2:user2 3:user3 4:user4 "
VNCSERVERARGS[1]="-geometry 1024x768"
VNCSERVERARGS[2]="-geometry 1024x768"
VNCSERVERARGS[3]="-geometry 1024x768"
VNCSERVERARGS[4]="-geometry 1024x768"
For your situation, make sure you enter valid user accounts for each user that you want to allow a VNC connection. In the example above, these are users user1, user2, user3 and user4. Also make sure that you create a VNCSERVERARGS entry for each user.

Create the users (if they don't exist already):
# useradd user1
# passwd user1
# su - user1
# vncpasswd
Repeat for the other users.

Add ports 5901, 5902, 5903 and 5904 to the firewall (tcp). This step depends on your Linux system.

Edit /home/user1/.vnc/xstartup:

# Uncomment the following two lines for normal desktop:
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 &
Copy this xstartup file to the home directory of the other users.

Restart the vncserver:
# service vncserver restart
Download & install TightVNC on your Windows desktop; you only need to install the Viewer.

Run TightVNC Viewer, and enter hostname:x (where "x" is the number of your display as defined in the vncservers file above, and where hostname is the hostname of the Linux server) as the VNC server, and click on Connect. Enter the corresponding password as set by the vncpasswd command and you should get a VNC window on your host.

If you found this useful, here's more on the same topic(s) in our blog:

UNIX Health Check delivers software to scan Linux and AIX systems for potential issues. Run our software on your system, and receive a report in just a few minutes. UNIX Health Check is an automated check list. It will report on perfomance, capacity, stability and security issues. It will alert on configurations that can be improved per best practices, or items that should be improved per audit guidelines. A report will be generated in the format you wish, and the report includes the issues discovered and information on how to solve the issues as well.

Interested in learning more?