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.

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.

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

Save the file.

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.

Add the following rules:

Save the file.

5. Restart the firewall.

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

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:

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.

Edit the vncservers file and type in the following:

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:

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

10. That’s it.

Advertising

When thinking about launching a site, time and money are of the essence. Time can be saved by getting the web design templates from online. And money can be saved by taking up courses like 350-030 to increase productivity and efficiency. Money can also be saved by doing some research and going for the cheapest domain hosting company. There are many, one of these is lunarpages. They even provide a dedicated server at a competitive price.

1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 4.5 out of 5)
Loading ... Loading ...

68 Responses to “Vncserver on Fedora Core 4”

  1. Thanks for this super little help blurb. I have been using RH9 for ever and decided to use FC4 on some new servers, but everytime I connected with VNC I would get an X windows screen, not the GUI I wanted. Your article saved me some time in the Google box.

    Thanks so much.

  2. I’m glad I was able to help a fellow FC4 user.

  3. Thanks a lot. I was really struggling with this and your instructions had me up and running in a couple of minutes. Great work!

    I would like to set things up so vncserver starts whenever the machine boots. If you have any advice in that regard, I would be very grateful.

    …Dale…

  4. Thanks, Ulysses!

    The easiest mean to an end this newbie has found.

    Cheers,

    Keith

  5. Dale, Keith,

    I’m glad I could be of help. I’ll add the instructions above to start the vncserver whenever the system boots up.

  6. Hi, Thanks I got this working. I am using a windows machine to connect to FC4 but when I connect I am connected as root. How can I connect as a user.

  7. Lee,

    You need to create a vncserver instance for your user. You need to login as the user and issue the command “vncserver” from the user’s home directory. See instructions above. You will then be prompted for a vncpassword. Enter it twice. The vncserver user will then be created. You need to edit .vnc/xstartup file. From there, just follow the rest of the instructions above. Good luck.

  8. Hey, this was EXTREMELY helpful. I had run into some page that said I needed to configure X before I could configure for VNC and when I used their instructions, most of which didn’t fit my situation with FC5, I screwed my system up so badly that reinstalling was easier(the fact I’d already re-installed 15 times that day didn’t help much with that decision..heh).

    Many kudos, I’m permanently bookmarking this page in case I have to do it again but it was so simple, I doubt I’ll need to.

    Thanks again

    Eric

  9. The 16 colors blows,. not sure what I can do about that..but at least it works, step 1!

  10. Can you fix the typos in the following line in iptables:

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

    it should have options -p tcp be –dport and — state (I think).

  11. Thanks a bunch, there are about 3 handholding walkthrough’s out there, and not one of them clearly told me to run the “vncserver” command once as my own user from my home dir… so it was almost set up but never worked.. so simple and so clear. Thx

  12. Howard, Thanks for bringing it up. I just doubled check the iptables rules again and they’re correct. Unfortunately, the font I’m using makes the double dash a longer dash.

  13. In order to get the firewall to work properly using Fedora Core 5 (FC5), I had to change the simple ‘-p’ to ‘-p tcp’. Otherwise the firewall chokes and gives a rules error.

  14. Thanks for a very useful page. Just a couple of things:
    1. In your March 6 post you indicated that you would add instructions on starting vncserver at reboot. Did I just miss them? (Currently stuck there.)
    2. It might help to point out the correspondence between port number and display number, in case it’s not obvious.
    3. Another post mentions that the location of .vnc is ’special’ for root, being stored under /.vnc instead of /root/.vnc …. While it may be a bad idea to allow access by root, could you confirm that?
    Thanks again!

  15. I should have noted that I =did= see your instructions under “addendum”, but that the service that pickes up that data doesn’t seem to start at boot time. Sorry.

  16. Alright. Last post — sorry to be verbose, but maybe it will help someone else. The trick was to “/sbin/chkconfig vncserver on”. Otherwise, the service wasn’t marked to be started at boot. There is probably a graphical way to do this (which should be described for completeness), but I was doing this remotely with only a terminal session available. Thanks again.

  17. Hi Clayton,

    Thanks for your comments. I thought about enumerating the steps above to bring more clarity to the instructions. I think that would help. Regarding root and vncserver. It’s NOT a good idea to run the VNC as root. The instructions mention how to create a vncuser from a regular user for good measure.

    Regarding /sbin/chkconfig, it’s a command used to activate and deactivate services at different runlevels. It’s also a command used for checking status. There was no need for me to invoke this chkconfig since I’m at runlevel 5 by default. But, if I wanted vncserver running at a different runlevel, then this would be the command to run. Just a couple of examples.

    Check status of vncserver:
    #chkconfig –list vncserver

    Activate vncserver on runlevels 3, 4 and 5.
    #chkconfig –level 345 vncserver on

    Thanks.

  18. Thanks. Out of the box (so to speak), the VNCSERVER service was “off” at all run levels, so nothing happened at boot time. I turned it “ON” (as you indicated) and things worked like a champ. Incidentally, “chkconfig vmcserver on” seemed to turn it on for 2345, and I’m enough of a newbie that I couldn’t remember the run levels and what I should have used. [Well, it's Alzheimer's, since I did unix sysadmin back in the 80's.] Also, on my box, sbin wasn’t in root’s path, so just typing “chkconfig …” didn’t work; I had to discover where it lived and run it from there. Thanks again.

  19. OK, one more plea for your kind assistance.
    I can connect to vncserver via TightVNC, receive the login prompt, log in, and log out. However, after that, if I try to connect as the same user, I get only the wallpaper, no fc4 login dialog. If I try a different user, the same cycle happens — and then I can’t log in for =that= user. If I reboot, I can once again log in successfully, but then the same situation arises — can’t log back in after logging out. Any ideas would be greatly appreciated — I’m =so= close! Thanks.

  20. Clayton, I use the Windows version of VncViewer instead of TightVNC. It could be TightVNC related. I don’t have any experience with TightVNC, so I can’t help you there. Another thing I should mention. When I log out of VNCViewer, I just close the app without logging out. So, when I start VNCViewer again, my desktop is readily available. I hope that helps.

  21. Ah … after many hours of trial n error google finally showed the way to your site - thank you for sharing the info! :)

    /kristian

  22. Thanks. I’ll see if I can find the Windows client and try it. Your point about not logging out may be the key — if I just close and don’t log out, TightVNC works as well. You might try logging out and see if you experience the same problem I do! (Thus possibly uncovering a problem with the server portions!)

  23. Clayton, I think it’s pretty standard to leave the user logged in, otherwise if you log out you’ll see just the wallpaper. Vncviewer does the same thing. By the way, there’s no need to reboot your machine if this happens. Just SSH to the machine to kill the vncserver and restart. Example:

    #vncserver -kill :1

    #vncserver -geometry 1018×712 -depth 16 :1

    After restarting vncserver, run TightVNC or Vncviewer again and that should take care of it without rebooting.

  24. Hey..i really appreciate you taking the time to type this up…i went through this little tap dance 2 years ago on rh9 but totally forgot how to do it again for fc4.

    one issue i’m having is this…when vnc session opens all the windows open as separate boxes and some apps don’t run..like services.

    any ideas?

  25. I got it.

    # Edit ~/.vnc/xstartup
    # For KDE, replace “twm &” with “startkde &”
    # For Gnome, replace “twm &” with “exec gnome-session &”

    plus i added runlevels 3 - 4.

    not sure with did for me…never the less it works.

    Marc

  26. Marc,

    Cool. I appreciate you pointing this out. I’m running twm. I’ll try this out. Thanks.

  27. Hi,

    I don’t know if anyone has checked it out but I’ve been using FreeNX and I consider it to be an incredible alternative to VNC. I’d been here before and found this place helpful so I figured I’d turn everyone onto FreeNX.

    Here’s a link

    http://fedoranews.org/contributors/rick_stout/freenx/

    It took me a minute to figure out which version of the NXserver was for FC5 but beyond that, it’s amazing and secure since it uses SSH to tunnel.

  28. Thanks for the link, Eric. Sounds promising. I’ll check it out. Thanks.

  29. Hi

    Evrithing is OK but ’su’ still dos not work .

  30. Running FC5 and for me the key is the iptables entry.
    FC5 must be explicitly told to enable vnc on install, otherwise you must iptables modify.

    Also noted earlier, the iptables addition did have a typo “tcp” missing
    -A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 5901:5909 -j ACCEPT

    Finally,
    additional thanks on the note to start /etc/X11/xinit/xinitrc
    without, causes gnome startup problems with power management.

    my vnc does work but there is still a difference in functionality/operation between FC3 and FC5. The FC5 has a problem when I try to move desktop icons, opens up FileRoller instead, work thru that later; again thanks, I can again work from home.

  31. This step
    /sbin/service iptables restart

    Gave an error as follows:

    Flushing firewall rules: [ OK ]
    Setting chains to policy ACCEPT: filter [ OK ]
    Unloading iptables modules: [ OK ]
    Applying iptables firewall rules: iptables-restore v1.3.0: Unknown arg `–dport’
    Error occurred at line: 19
    Try `iptables-restore -h’ or ‘iptables-restore –help’ for more information.
    [FAILED]

    The rule that I added to my iptable is:
    -A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p
    –dport 5901:5909 -j ACCEPT

    What am I doing wrong?

  32. Heidi,

    Like Ajax 4Hire had said, there’s a missing “tcp” in the firewall rules. I have yet to confirm, but I will get back to you shortly.

  33. Boogers!
    I did a search on “vnc move icon fail bug FC5″ because I still have problem with desktop icons. When I try to Click-Hold and move a desktop icon, I get File Roller launched and no icon move. So excited when I found a hit of almost the exact problem only to find that it was what is written above by Ajax4Hire.

    Still have the problem:
    Running FC5, starting vncserver, everything runs ok but when I try to re-arrange desktop icons, the File roller starts, Its driving me crazy.

    Any help anyone has on this would be appreciated.

  34. I corrected the missing tcp on the firewall rules on one of my comments that created a couple of problems for people. As far as the Fire Roller Ajax 4 Hire mentioned, I couldn’t replicate the problem.

  35. Greetings and thanks for the info, nice page! I am still having a bit of a problem though, the server start fine (no errors) and the firewall rule is showing up OK but when I try accessing it from my PC it get the error message: “The connection closed unexpectedly” if I retry the message is “Too many security failures”

    Have a direction to point me in?

  36. CCooper I have the same problem and it actually only started today.
    When I look at the server log I see the following
    Connections: accepted: 192.168.2.100::2714
    SConnection: Client needs protocol version 3.8
    SConnection: Client requests security type VncAuth(2)
    SConnection: unexpected security type
    Connections: closed: 192.168.2.100::2714 (unexpected security type)

    Any suggestions would really be appreciated

  37. I’m curious why you guys are connecting on port 2714 instead of 5901 to 5909. Try adding port 2714 in the firewall rules. Use the same example shown above, but using port 2714.

  38. I am not using port 2714, my connection is over 5901, I am not sure why Eranc gets the reference to 2714 in his log file.

    My problem is a bit different, here is the scenario: I have 4 systems running FC3, FC5, SuSE 10.1 and UNIX (HP-UX). I have vncservers running on all four systems and access them from a Win-XP running REAN-VNC 4. I can access all except the FC5 system. When I try I get “connection closed unexpectedly, Do you wish to reconnect to …?”
    If I say yes after a couple of tries I get the “too many connection failures…” message

    I can access the other three sytems just fine, now for the odd part, if I first vncviewer into the SuSE 10.2 system and from it launch vncviewer to the FC5 system it works just fine !!! but if I try accessing it from any of the other 3 systems or my laptop it fails with the above messages…

    So I know the server is running, nmap shows the ports are active and each of the other systems can succesfully launch a viewer to each other with the only holdout being the FC5 system which olny works when accessed from the SuSE 10.2 system. Wierd.

  39. OK, I found the problem, My Real-VNC viewer wasn’t using VNC protocol 3.3, when I set the option to “Only use Protocol 3.3″ it works. I may need to explore the options more fully to see if there is a auto-config or something but at least it is working ! 8^)

  40. Thanks everybody for sharing the knohow :-)

  41. Great discussion I also had some problems with the config. Now it works great.

  42. This was very helpful. Thanks for posting it. As a note to everyone; Tightvnc works “out of the box” with the 3.3 protocol.

  43. You wouldn’t believe how many tutorials on this subject I have read over the past few weeks. This one is the only tutorial that stepped me through the entire process and resulted in a working system. Thankyou !!!

  44. Kurt, Richard,

    I’m glad you found this little write-up helpful.

  45. I get this after step 1.
    [root@66-226-79-106 ~]# vncserver
    vncserver: couldn’t find “xauth” on your PATH.

    also the system tells me that .vnc does not exist.

    Thanks!

  46. Hi Jeff,

    In step 2, you need to be perform this step as a regular user and not root. That should take care of it. Let me know how it goes.

  47. Hi Guys,

    Nice walktrough here…I was able to setup a VNC connection from my WIN PC to the FC5 machine.
    And belive me…my linux experience can be counted in hours :) I have a nice colored desktop…all in all everything looks fine…with one exception:
    No matter what application I open (FF, IM) I cant see it in the VNC window. Its like its minimized and … nowhere on the taskbar…
    Anyone had this kind of issues?
    Thanks

  48. Hmmm, interesting. I’ve never seen this behavior. Hopefully, somebody can help.

  49. hey,

    finally i got it….the problems was comming from the resolution and color depth settings ;)
    well…finaly starting to enjoy this SO

  50. Excellent article… saved my much frustration getting VNCServer running on Fedora Core 5

    Cheers!

  51. 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…

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

  53. 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.

  54. 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

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

  56. 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.

  57. 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. :)

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

  59. 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.

  60. 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

  61. 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.

  62. 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!!

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

  64. 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.

  65. 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]#

  66. 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.

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

Leave a Reply