Vncserver on Fedora Core 4

I’m posting this article to document the setup and configuration of vncserver on my Fedora Core 4 desktop. I’ve had a hard time finding the right documentation online. So, I’m making this document available to anyone who might be looking for help configuring the vncserver on the Fedora Core 4 and 5 platform. And now, Fedora 6 as well. Let’s get started.

1. If you haven’t installed the vncserver yet, type in the following commands from the bash console to start the installation process.

yum -install vnc-server

2. The following commands takes you to your home directory and starts the vncserver configuration. You’ll be prompted to enter your vncserver password twice. Vncserver will then create several files in the .vnc directory underneath your home directory.

cd
vncserver

3. Change directory to .vnc directory and edit the xstartup file and remove the “#” uncommenting the following lines:

unset SESSION MANAGER
exec /etc/X11/xinit/xinitrc

cd .vnc
vi xstartup

Save the file by typing “:wq”

4. If the firewall is NOT installed, skip the next two steps. Otherwise, login as root. Change directory to /etc/sysconfig. Edit the iptables firewall.

su
cd /etc/sysconfig
vi iptables

Add the following rules:

-A RH-Firewall-1-INPUT -m state --state NEW
-m tcp -p tcp --dport 5901:5909 -j ACCEPT

Save the file by typing “:wq”

5. Restart the firewall.

/sbin/service iptables restart

6. Start the vncserver with the following options. If successful, you will see a message stating the server has been started.

vncserver -geometry 1024x768 -depth 16 :1

7. Now access the vncserver from another machine, using either a Windows or Linux machine. You can use the vncviewer program which is available for both Windows and Linux platforms.

From Linux, enter the following command:

vncviewer hostname:1

From Windows, start vncserver application and type hostname:1 in the dialog box.

Enter your vncserver password!

Addendum:

8. Perform the following commands to make the vncserver server start at boot time. Login as root. Change directory to /etc/sysconfig.

su
cd /etc/sysconfig
vi vncservers

Edit the vncservers file and type in the following:

VNCSERVERS="1:user1 2:user2"
VNCSERVERARGS[1]="-geometry 1276x968 -depth 16"
VNCSERVERARGS[2]="-geometry 1024x768 -depth 16"

Save the file and reboot. I tried restarting vncserver via Services without rebooting, but it didn’t work for me. So, a reboot is necessary. The vncserver should start automatically after each reboot.

9. Finally, if you like to run the vncserver on several runlevels other than the default 5, perform the following commands.

Check status of vncserver:

chkconfig --list vncserver

If you like to activate vncserver on different runlevels, for example 3, 4 and 5.

chkconfig --level 345 vncserver on

10. That’s it.

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • StumbleUpon
  • Twitter
  • RSS

71 Responses to “Vncserver on Fedora Core 4”

  1. Sabine says:

    Hi,

    firstable thanks for the excellent guide.

    I have one problem other people around me also have. When I connect with a VNC-viewer (I use tight-VNC), I do not see the screen running at the server but a different screen. I suppose that is, because the VNC-server is started with :1, isn’t it? And :0 does not work, I tried already.

    Does someone know any possibility to connect to the original screen? I would be thankful for help…

  2. Amore says:

    Luogo interessante, buon disegno, lo gradisco, signore! =)

  3. zakala says:

    Thanks for an excellent walkthrough. I’ve been using various flavours of linux for a while, but fedora handles vnc “differently” and had me confused for a while there.

    It now works fine.

    And in answer to Sabine, what you want is what my fedora 6 install was doing by default – I started vnc via services, but could only connect to a logged in desktop. I just set the password in the remote desktop preferences and started vnc in services.

  4. Warren says:

    Hi there,

    seems to be a great discussion. I have a question though.

    How do you get the same instance of the KDE Desktop when u VNC into the FC4 box? I mean, like at work, my desktop is running FC4 and KDE running. SO what i want to do is when i get home i will be able to connect in and see the same desktop as when i left work?

    doing startkde in xstartup file will start a new instance of KDE which is not what i want. If anyone know please email me ngwar1030@sbcglobal.net

    thnx
    warren

  5. Randall says:

    Thanks! The instructions were just what i was looking for!

  6. Mylton says:

    I have a stupid silly question….the instructions are so straight forward and eased my headache. THis is my first step in the linux world. And learning how to run commands in the backend is a bit scary. In any case…if Im using putty and im in remotely, when you say Save the File? what do you mean….moreso what commands do I need to enter to do that….I have googled high and low and not sure how.

  7. ulyssesr says:

    Mylton,

    Welcome to the world of vi. There are dozens of vi tutorials online, but to answer your question, you will need to use :wq to save a file. w is write and q is quit. You seem to be doing fine with vi since you managed to find the insert command. :)

  8. Mylton says:

    Thanks for the clarification. Is this the same command for the firewall?

  9. Mylton says:

    I got it to work :) great……thanks again

    Now for another stupid question, is there a way to actually see the GUI through VNC? Or is everything console, reason being I ould much rather use putty, than VNC if that is all I can do.

  10. mark john says:

    hi,
    This is a godd article. I have setup the vncserver within no time. Also I got the GUI setup by starting the vncserver with the name option
    $vncserver -name gnome

    This lets me to get the gnome desktop to my vncviewer.
    -mark
    Developer UK & USA Wholesalers

  11. dougs says:

    After reading very carefully and applying those elements that fit my situation I was able to get things to work as expected, including the KDE desktop. A most helpful string of postings and it is very much appreciated by this humble newbie.

  12. Lucas says:

    i have two fedora linux running at home, the default port for VNC of course is 5900, but i need a different port for my the other computer, so how actually i can change the port other than 5900. Would appreciate if someone can help up!!

  13. ulyssesr says:

    Doug, I’m glad you got it to work.

  14. ulyssesr says:

    Lucas,

    When you edit /etc/sysconfig/vncservers like below.

    # VNCSERVERS=”1:user1 2:user2″
    # VNCSERVERARGS[1]=”-geometry 1276×968 -depth 16″
    # VNCSERVERARGS[2]=”-geometry 1024×768 -depth 16″

    The first vncserver argument is port 5900.
    The second vncserver argument is port 5901 and so on.

    On the client side:
    # vncviewer hostname:1
    # vncviewer hostname:2

    Hope that helps.

  15. Paul says:

    I went through everything (needs better documentation on how to save a file though) and all went well however when i ran the line below i got that error. Cant restart my firewall. Any ideas?

    [root@s15258023 sysconfig]# /sbin/service iptables restart
    Applying iptables firewall rules: iptables-restore: line 1 failed
    [FAILED]
    [root@s15258023 sysconfig]#

  16. csaba63 says:

    The instructions in the article also apply to Fedora 8. The only change (already noted in some reader-feedback) is about the additional line within the firewall rules: a missing “tcp”. The entire line should read:
    -A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 5901:5909 -j ACCEPT

    So far still the best article on setting up vnc.

  17. ulyssesr says:

    Csaba63. I’m glad the instructions still apply to Fedora 8. I added the missing tcp in the firewall section. Thanks.

  18. Raja says:

    Hi,

    Thank you very much, it has been worked…

    Thanks,
    Raja

  19. nelson says:

    Very good content.

    But, Why other users can logout gnome by VNC and can login again after service vncserver restart while ROOT cannot ? How to restore / fix ?

  20. nizar says:

    hello
    thanks a lot for this effort

    i am facing this in step two:

    vncserver: couldn’t find “xauth” on your PATH.

    although i wasn’t accessign through root

Leave a Reply