Setting up VNC on a Linux box is always such a hassle. But I had to do it again today so that I don’t have to deal with two sets of mic and keyboards when I am testing my work in VMWare.
Thank goodness for this article that I saved a bunch of time having to figure things out myself. Maybe in the [always] good old college days, I’d have done that. But now time is of utmost importance with an active child in the house and all…
The only hiccups I got was that the above setup failed to discuss the issue with firewall and iptables. To allow outside access (even within the same home network), a port must be open to allow the traffic to flow through. There are a couple of ways to do that:
Adding a rule through a GUI in Gnome:
1. Go to
1 System -> Administration -> Security Level and Firewall2. (enter the appropriate password when prompted)
3. Under the
1 Firewall Optionstab, click on the white arrow at the bottom that’s labeled
1 Other ports4. Click on
1 Addand enter the port number you are allowing access; in my case, it was
1 5902for display number 2. (Leave the
1 protocolat default, which should be
1 tcp5. Click
1 OKall the way out, and iptables should have been restarted with the rule in place
A geekier way to do it is through command prompt:
1.
1 sudo vi /etc/sysconfig/iptables2. Add the following line to the rule:
1 -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5902 -j ACCEPT3. Restart iptables by issuing:
1 sudo /etc/rc.d/init.d/iptables restart
Another thing that many Linux novice (like myself) don’t quite grasp is the fact that Linux’s GUI is not at all tied to the operating system. You can have Gnome, KDE, Flux or Blackbox as GUI options installed on the same OS. And you can switch around as you please upon setting the preferred desktop and log/in again. When you are viewing the remote system through VNC, you can do exactly the same thing — you can define what type of GUI you want to see as you launch your preferred VNC viewer client:
Edit
1 /home/_vnc_user_name_/.vnc/xstartupas such:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 #!/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" &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" -e ./menu &
#twm &
#fluxbox &
gnome-session &
#startkde &
Noticed I commented out (#) some desktop GUI options at the bottom except Gnome. Basically you can use any one of them anytime as long as you restart the
1 | vncserver |
after you’ve made the changes.