Configure VNC Server on Fedora

In computing, Virtual Network Computing (VNC) is a graphical desktop sharing system that uses the RFB protocol to remotely control another computer. It transmits the keyboard and mouse events from one computer to another, relaying the graphical screen updates back in the other direction, over a network.

VNC is platform-independent – a VNC viewer on one operating system may connect to a VNC server on the same or any other operating system. There are clients and servers for many GUI-based operating systems and for Java. Multiple clients may connect to a VNC server at the same time. Popular uses for this technology include remote technical support and accessing files on one's work computer from one's home computer, or vice versa.

- From Wikipedia -

Configure VNC Server in Fedora (or maybe in other GNU/Linux systems) is different like we usually done in Windows, it's definitely far from "Click -> Next -> Finish" thing. But don't worry, it's not always that hard in practical.

First Thing First: "Install VNC Server"
$ su -c 'yum install vnc-server vnc'
I will skip the explanation of this part :D

The Second: "Configuration"

On Fedora system, the VNC Server configuration is located at: "/etc/sysconfig/vncservers". Let's edit the configuration file:
$ su -c 'vim /etc/sysconfig/vncservers'
Find this line at the bottom of the file:
VNCSERVERS="2:myusername"
VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"
I recommend you to change it like this:
VNCSERVERS="1:yourdesiredusername"
VNCSERVERARGS[1]="-geometry 1024x768"
yourdesiredusername is the username that you allowed to access VNC. Please note this part, the prefix number on
"2:myusername"
or
"1:yourdesiredusername"
is Xorg display that you want to use for VNC.

If you use display number 2, and then VNC Server will use TCP Port 5902 (5900 + 2). So, when you prefer to use port 5901, you have to change display number to 1. And dont forget to change also display number argument on VNCSERVERARGS[display_number].

The Third (Last): "User Password & XStartup"

Login as the user that you've specified on VNC Server configuration and then run:
$ vncpasswd
You will be prompted with password and confirmation dialog. As soon as you finished, edit the xstartup configuration with this command:
$ vim ~/.vnc/xstartup
Change it like this:
#!/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
gdm &
This configuration allow VNC to use normal desktop access with GDM (GNOME Display Manager). Default configuration only allow VNC user to use TWM and XTerm (why do we need VNC if we're just want to access the terminal :p).

Ok, now we start the VNC Server service with this command:
$ su -c 'service vncserver start'
Password:

Starting VNC server: 1:yourdesiredusername
New 'your.host.name:1 (yourdesiredusername)' desktop is your.host.name:1

Starting applications specified in /home/yourdesiredusername/.vnc/xstartup
Log file is /home/yourdesiredusername/.vnc/your.host.name:1.log          [ OK ]
If you want to enable this each time computer boot, just run this command:
$ su -c 'chkconfig vncserver on'
Before you try access with VNC Client, remember to open firewall port that you use for VNC Server. In this example, we need to open TCP Port 5901.

Now you can run VNC Client to connect to this VNC Server with this address:
your-vnc-server-host:5901
or
your-vnc-server-ip:5901

Happy Remoting!