Vncserver is just another application available in almost all the available Linux based distros. Configuring vncserver is very easy. But the default desktop view in vncviewer is gray scale desktop with very pathetic GUI. To view normal Gnome or KDE desktop in vncviewer, assigning a custom port for usage, user configuration and to adjust the resolution of the vncviewer window, some files need to be configured properly. Here are the required configuration in any version of Fedora/Fedora Core. But with minor modifications these can be applied to other distros like Ubuntu, SuSE, Gentoo etc.

Step 1: Installing Vncviewer, Vncserver

As root do this

[root@bordeaux saini]# yum install vnc [Enter]

Step 2: Configuring resolution, port & user

The default location of server configuration file for vncserver is ‘/etc/sysconfig/’. To configure the resolution, user and port open ‘/etc/sysconfig/vncservers’ in you favorite editor and add two lines per user configuration shown ..

VNCSERVERS=":"
VNCSERVERARGS[]="-geometry x x"

Example :

VNCSERVERS="3:saini"
VNCSERVERARGS[3]="-geometry 1000x700"

You can choose any display port, but it should not be in use by another X server. Window height and width can be anything (not in fraction of course). But keep in mind that the system on which you are going to view the desktop using vncviewer should have greater resolution than what you specify here, otherwise scrollbars will appear.

Step 3: Configuring Desktop Environment

The user specific configuration files of vncviewer resides in ‘.vnc’ directory in user’s home directory. (e.g. ‘/home/saini/.vnc/’). Open ‘.vnc/xstartup’ in your favorite editor and edit as below

  • For Gnome

The ‘xstartup’ file shout look 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
#vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
startx &
  • For KDE

The ‘xstartup’ file should look 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
#vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
startkde &

Step 4: Configuring password

For setting up vncviewer password for user ‘xyz’, login as user ‘xyz’ and issue ‘vncpasswd’ command on a terminal/konsole (or whatever). Enter password twice and you are done with password setting.

Step 5: Starting Vncserver

To start vncserver, login as root and issue ‘service vncserver start’ command. If service started successfully, you are ready to use vncviewer on a remote/local machine.

Step 6: Accessing through Vncviewer

  • From Linux based machines
[saini@bordeaux saini]# vncviewer IP_Address:displayPort [Enter] #(IP Address is for the machine where you set up vncserver)
  • From Windows

On windows there is a software called RealVnc. Install it and enter <IPAddress>:<displayPort> in the dialog box.
[I explained how to connect via windows because it may help someone get a bit of relief.]

Screenshots:

  • Vncviewer with Gnome as Desktop environment

VNC Server VNC Viewer Screenshot GNOME

  • Vncviewer with KDE as Desktop environment

VNC Server VNC Viewer Screenshot KDE

Vnc is nice tool if you want to avoid using windows. I use it all the time. While I am forced to work on windows system, I install vncviewer and use it in full screen mode :P It also helps when you want to run some gui based application and monitor is remotely. Because if you close vncviewer window and use vncviewer again, you will be given the desktop session where you left it (all windows open and applications running).

Related Posts

{ 1 trackback }

Using vnc in RHEL
July 4, 2011 at 6:06 PM

{ 32 comments }

1 Bharat December 2, 2007 at 11:01 AM

Although, i didn’t go thru the whole thing and i don’t know what gray scale is but vnc just works! i mean, ur configuration regime seems overkill to me or is there something different to this from the normal simple way ?
at least, the desktop screenshots tell me its the same thing.

2 Siddharth Singh January 17, 2008 at 4:34 AM

hey i have been using vncserver to connect to my gnome desktop in fedora 8.
but theres a problem . i dont get the panels , close , minimize buttons etc on windows and wiondows is not movable, it just sticks to the top left corner of screen.

if u can then please help.
waiitng for ur reply thnaks !!

3 Siddharth Singh January 17, 2008 at 4:55 AM

i found something more whenever i connect to remote gnome desktop i get a bug report saying
gtk-window-decorator has crashed

4 General Bordeaux January 17, 2008 at 6:39 AM

@Siddharth
I think you are trying to use compiz/beryl or something like that and that is enabled when you login. That might be causing the problem. Can you check that out.

5 Siddharth Prakash Singh January 17, 2008 at 8:05 AM

hey i got thru !!
thanks
compiz-fusion was creating the problem

thanks again

6 Dan Sandoval February 26, 2008 at 10:21 AM

Greetings:

Windows vncviewer to fedora 8 works great if a user is logged in.
How can I get fedora 8 to allow Windows vncviewer to work when no user is logged in?

Thanks
DanO
spookeetooth@msn.com

7 General Bordeaux February 26, 2008 at 11:42 AM

@Dan

Windows vncviewer works great irrespective of the situation whether a user is loggen in or not. There may be some problem with your configuration files. Paste you configuration files somewhere n I’ll see if I can help.

8 user March 25, 2008 at 11:10 AM

using vncviewer to connect on a remote desktop with KDE, is working, but what i see is not the current desktop on the remote machine, is a new KDE desktop. i can’t see what aplications are running on the remote machine.
that is working with vnc server on windows machines.

9 General Bordeaux March 25, 2008 at 11:33 AM

@user you have to use Remote Desktop application that is available in Fedora 8 by default with vncviewer. Only then you can see the apps running on the remote machine.

10 user March 25, 2008 at 12:14 PM

i’m using vncviewer on local machine, and conf files on remote machine are
this:
——————————————————————————————————
# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the lines below to start a VNC server on display :2
# as my ‘myusername’ (adjust this to your own). You will also
# need to set a VNC password; run ‘man vncpasswd’ to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted! For a secure way of using VNC, see
# .

# Use “-nolisten tcp” to prevent X connections to your VNC server via TCP.

# Use “-nohttpd” to prevent web-based VNC clients connecting.

# Use “-localhost” to prevent remote VNC clients connecting except when
# doing so through a secure tunnel. See the “-via” option in the
# `man vncviewer’ manual page.

VNCSERVERS=”1:romeo”
VNCSERVERARGS[1]=”-geometry 1024×768″

——————————————————————————————————
and:
——————————————————————————————————

#!/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 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &
startkde &

——————————————————————————————————
for example, on local machine i’m logged with kopete on my yahoo messenger
acount, and every time i launch on local machine

vncviewer IP:1

i’l be logged out from kopete because kopete is launching on remote machine

11 user March 25, 2008 at 12:46 PM

i’m using vncviewer on local machine, and conf files on remote machine are
this:
——————————————————————————————————
# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the lines below to start a VNC server on display :2
# as my ‘myusername’ (adjust this to your own). You will also
# need to set a VNC password; run ‘man vncpasswd’ to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted! For a secure way of using VNC, see
# .

# Use “-nolisten tcp” to prevent X connections to your VNC server via TCP.

# Use “-nohttpd” to prevent web-based VNC clients connecting.

# Use “-localhost” to prevent remote VNC clients connecting except when
# doing so through a secure tunnel. See the “-via” option in the
# `man vncviewer’ manual page.

VNCSERVERS=”1:romeo”
VNCSERVERARGS[1]=”-geometry 1024×768″

——————————————————————————————————
and:
——————————————————————————————————

#!/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 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &
startkde &

——————————————————————————————————
on local machine:

vncviewer :1

and i don’t see aplications running on remote machine

12 General Bordeaux March 26, 2008 at 6:25 AM

This is normal vncviewer behavior. You must use Remote Desktop utility if you still want to be logged in which was introduced in Fedora 8.Checkout http://linux.saini.co.in/2007/11/10/fedora-8-final-review/ and look for remote desktop utility.
Though it not safe to use Remote Desktop, you can use it if you are not pretty much worried about security. Checkout http://www.opensubscriber.com/message/fedora-devel-list@redhat.com/8155623.html.

13 Dar September 1, 2008 at 12:44 PM

hi Mr.Saini

i’m using ubuntu..how to configuration in ubuntu???

because i read, you wrote :
“Here are the required configuration in any version of Fedora/Fedora Core. But with minor modifications these can be applied to other distros like Ubuntu, SuSE, Gentoo etc.”

what are the minor modifications???

14 kulbirsaini September 4, 2008 at 8:39 PM

Did you try with the given configurations? I wrote minor modifications because I am not sure if it works. Can you please try with the configurations given here?

15 VNC Server Configuration | Pedro Santos September 9, 2008 at 1:30 AM

[...] How to configure vncserver? [...]

16 visitor October 19, 2008 at 6:19 PM

VNC Server is only capable of providing access to session zero. If a different user session is the active console session whena VNC viewer connects, VNC Server will attempt to make session zero the console session.
alarm systems

17 kulbirsaini October 19, 2008 at 6:37 PM

I am not really able to get what you are trying to state?

18 Nathanm October 30, 2008 at 6:46 PM

I’m trying to get the VNC server running on an FC3 distribution. I’ve followed your instructions and everytime I try to start Xvnc with vncserver, I get a ‘failed’ message. (i’m doing this from CLI.)
What should might be preventing it from starting up?

19 kulbirsaini October 30, 2008 at 9:06 PM

Try this on command line
[root@localhost root]# Xvnc :1 [Enter]

if this also fails, try 2,3,4 or any other higher integer instead of 1. If you still get the error, then paste the exact error you are getting.

20 Anonymouse January 22, 2009 at 6:04 AM

Trying this for 4 days now, no success….the files you mention to edit under sysconfig are not editable at all.
It’s totally beyond me why a task that lasts 2 minutes on a win XP machine like installing VNC server and letting it run properly, takes 4 days on a linux machine.
Why do we have to configure so many things, with close to no help, no documentation and no logic behind it?
Fedora is as unusable as ever… Even with this guide … Even the very first steps of this guide asume you can edit all these files… well I can’t.

21 kulbirsaini January 22, 2009 at 12:18 PM

Do you have sufficient permissions to edit those files? To edit anything in /etc/sysconfig you need to be root.

22 caracuri January 28, 2009 at 12:23 AM

vncviewer connect but i see only a gray blank page.

23 VNC Server Configuration | EvRBlog June 1, 2009 at 8:34 PM

[...] How to configure vncserver? [...]

24 pkj December 1, 2007 at 5:08 PM

The persistent desktop due to VNC is really useful. Highly recommended to everyone.

I use VNC with IceWM.

25 Jarrod December 14, 2009 at 5:44 AM

This is a good article, but I think you need to add the appropriate firewall rule changes.

26 joann January 10, 2010 at 8:33 PM

I agree with Jarrod. It does need to be up to date. let us know. Thanks!

27 David Legg January 22, 2010 at 8:17 PM

This is a useful article.
How about updating it for Fedora 11/12?
Most of it could stay the same, but the yum package might be tigervnc-server.
No doubt there would be a few other tweaks uncovered by trying it …

28 Jonathan Konrad April 12, 2010 at 1:58 AM

These instructions appeared to work on Fedora 12 until till I tried to connect. Then all I get is a black screen at the dimensions I specify. It’s not my local client since I have tried three different ones from two different machines.

Is it the firewall? The Fedora 12 box is running headless so it is not “logged in”. I’m trying for a solution which will work in that state. Actually I’m using the box with the Amahi server package. Very cool. Anyway, I would appreciate any VNC help with my Fedora 12 box. Thank you.

29 Jason October 19, 2010 at 2:58 PM

For recent Fedora distributions, don’t forget you have to

yum install tigervnc-server

Otherwise, you just get the viewer

30 Steven P October 31, 2010 at 12:10 PM

Doesn’t work at all on FC13. Nothing but blank screens or black screens.

I’ve configured this easily many times on older FC6-8 machines no problem.

31 John p November 12, 2010 at 3:59 PM

It worked great for me. Thanks for posting the instructions. I can’t seem to get the display greater than 800×600 though, but now I can access the machine remotely and with a usable display.

32 jason October 5, 2012 at 6:59 AM

There’s no vncservers in /etc/sysconfig even though I did yum -y install vnc and yum groupinstall “GNOME Desktop Environment”.

[root@server sysconfig]# ls -a
. i18n named readonly-root snmptrapd
.. init netconsole rsyslog sshd
cbq ip6tables-config network samba wpa_supplicant
console iptables-config networking saslauthd xinetd
crond man-db network-scripts sendmail
httpd modules rdisc snmpd

Comments on this entry are closed.

Previous post:

Next post: