VNC, Transparently

Secure, transparent and ubiquitous desktops with VNC and OpenSSH, Part 1 of 2.
What's Happening?

When the server boots, it will run the VNC server for each user in the /etc/sysconfig/vncservers file. As it starts up, the VNC server reads the .xsession file in your home directory and will use it to run your preferred window manager. Then the VNC server will simply sit in RAM, waiting for a connection (either a local connection or one from over the network).

Figure 3. The Whole Process

The display manager also starts up at boot time, which presents you with a graphical login banner.

A user who does not have the VNC server configured, and who does not have the proper .xsession file in his or her home directory, will get a normal X desktop when logging in to the display manager. A user with all of these things configured will get the VNC desktop and also will be able to access the VNC desktop from anywhere on the network. Doing so securely, however, is a tale for the next article.

Drawbacks and Other Options

The setup I've described here has many advantages. For me, the primary advantage is the ability to access my desktop's state from any computer at work, which is nice if I'm on the other side of the site with a half hour between meetings, and I want to check my e-mail or my calendar.

A major drawback of using VNC as your default desktop is that you lose graphical performance. For example, playing movies on your VNC desktop is slow, due to long redraw delays. Most fast-action games are slow as well. Also, when the VNC server runs, it acts like an X server to all the applications that you run, but it is not accelerated in any way. Even if your true X server is accelerated, you won't be able to take advantage of it. (You can log out, log in as a different user, play the movie or the game, log out when finished, then log in again as your normal user. Your original desktop will be sitting there just like you left it.)

This configuration doesn't scale well for multiple users. You could define many VNC sessions in the /etc/sysconfig/vncservers file to start up at boot. But all of these VNC desktops will be idle until they are used. And for each VNC desktop, a VNC server is run, a window manager is run and, in the case of GNOME or KDE, many auxiliary applications are run. All of these take up RAM, and they may compete with each other for resources like the sound card. Similar commercial solutions like Citrix MetaFrame and Microsoft Terminal Server call for seriously powerful computers to support many users, and I'd guess this solution would work just as well on such hardware.

One alternative solution is to use XDMCP, which is how the traditional X world provides remote X access (à la X terminals). But in doing so you lose statefulness because the desktop is restarted every time a connection is made to the server, and you lose the ability to share the same desktop both remotely and locally. See the documentation for your display manager (xdm, gdm or kdm) or www.linuxdoc.org/HOWTO/XDMCP-HOWTO for more information.

Another solution is to run VNC out of inetd/xinetd, using the -inetd option. Doing so, however, causes the VNC server to start anew for every connection, disallows multiple connections to one desktop and shuts down after the original connection exits. So it loses statefulness and the ability to share the desktop both remotely and locally. See the VNC server documentation for more information.

Another option is x0rfbserver. This is an application that you run in your normal X desktop that will relay the contents of the desktop to a VNC client. It works well and will let you take full advantage of any accelerated video cards that your X server supports. It also is less RAM-demanding than running an X server plus a VNC server (it only requires an X server, besides the x0rfbserver itself, which is fairly small). But it requires that you always keep your X desktop running on the console, so it will not scale for multiple users. See www.hexonet.de/software.en for more information.

email: jdimpson@acm.org

Jeremy D. Impson is a senior associate research scientist at Lockheed Martin Systems Integration in Owego, New York. There he's a member of The Center for Mobile Communications and Nomadic Computing, where he uses open-source software to develop mobile computing systems. He can be reached at jeremy.impson@lmco.com.

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: VNC, Transparently

High_Noonan's picture

This is exactly what I am trying to do on Red Hat 9.0, but I am having trouble finding what the window manager is called for BlueCurve. Anyone know?

I want each of my user accounts to be able to fire up a VNC connection and and be asked for their username and password.

Has anyone gotten this to work in RH9.0?

I had access to my root account via RH7.2, but my hard drive blew up and I am forced to rebuild everything. :(

Send me a Private Message if you can help.

Re: VNC, Transparently

guppy's picture

I got this to work with RH9.0.

I did have to change .xstartup and .xsession though.

.xstartup:

#!/bin/sh
gnome-session &

and chmod u+x that file.

.xsession:

#!/bin/sh
exec vncviewer -truecolour -passwd $HOME/.vnc/passwd -fullscreen localhost:1

and chmod u+x that file also.

You are probably using Gnome as your window manager or KDE. BlueCurve is just a theme.

Jeff

Re: VNC, Transparently on SUSE ?

Anonymous's picture

Hi

I've recently installed vnc on SUSE and would like to automate the vncserver startup when the system boots / reboots.

I have notice some differences in the files referenced in this article re: Red Hat and SUSE. Could someoen suggest a script for me for SUSE and where to put it etc etc?

Gianni

ps. I have only recently begun using Linux so I am pretty unfamiliar with it

Re: VNC, Transparently, at boot

Anonymous's picture

Anybody know how to load vnc @boot without the redhat scripts I'm using gentoo, /etc/conf.d/local looks like:

start-stop-daemon --start --chuid root:root --exec /usr/bin/vncserver -- :1

vncserver starts and I can connect I see the windowmanager (fluxbox) but cant launch any apps! no errors are recorede because when vncserver starts (from local, after xdm) it says it's trying to log to //.vnc/host.domain:1.log ... this path is missing "root" or the name of the user... since I specified --chuid i dont get it. I searched allover, tried to mod the vncserver.init script to work with gentoo... no dice yet.

Re: VNC, Transparently, at boot

Anonymous's picture

If you are using the standard perl script, it uses username and home environment variables during startup. If you are root trying to start it for some one else you will have problems with your environment.

Re: VNC, Transparently

Anonymous's picture

How do I change my window manager to KDE, I'm not real sure

Re: VNC, Transparently

Anonymous's picture

Has anyone made this work with a non-Redhat distribution? I'm using Gentoo Linux and the init.d and sysconfig stuff wasn't included with the vnc install. I've downloaded the RedHat .rpm file and extracted the files, modified them to the best of my knowledge but there are just too many differences between RedHat and my distribution.

Re: VNC, Transparently

Anonymous's picture

You are right the /etc/rc.d/init.d/vncserver and /etc/sysconfig/vncservers files only exist on redhat based machines. I had to write my own startup script. The principle still applies though. You could write your own or convert Redhat. I wrote mine for a company so I can't disclose it.

Re: VNC, Transparently

Anonymous's picture

Just emerge vnc or tightvnc and follow the instructions.
Instead of changing your $HOME/.xsession, add a file named "vnc" or similar to your /etc/X11/Sessions, containing "vncviewer -passwd $HOME/.vnc/passwd -fullscreen localhost:1". Make sure it is read- and executable by everyone!
Restart your window-manager and choose "vnc" as session-type.

Re: VNC, Transparently

Anonymous's picture

I use Gentoo at home and a combination of Solaris, NT, W2k, and Cygwin at work. You should be able to just type

emerge -s vnc

and install one of the resulting packages in the usual manner. I have had sucess with TightVNC at home and connecting to this machine via ssh port-forwarding from work sites.

Re: VNC, Transparently

Anonymous's picture

Has anyone made this work with a non-Redhat distribution?yes, in fact i just [remotely!] installed it on my trusty potato server (a.k.a. Debian GNU/Linux 2.2), and was able to execute it and connect from the windoze client without any problems.

if you're having trouble with GenToo, however, i would suggest compiling the source files from the official VNC site (now owned by AT&T) at http://www.uk.research.att.com/vnc/download.htmlpeace-p

Re: VNC, Transparently

Anonymous's picture

Has anyone else experienced kdm crashing on vnc? I have redhat 7.1 - I get "The application KDE Splash Screen (ksplash) crashed and caused the signal 11 (SIGCEGV)." Further investigation allows me to get a window using twm but starting kedit or other kde programs causes a signal 11...It's kde 2.1.1. kde works fine on the console.

Re: VNC, Transparently

Anonymous's picture

Got the same error.
(also on RH7.1 & KDE 2.1.1)
(vnc-server-3.3.3r2-14 from the standard RH distro)
tvm works fine

vnc log says:

QImage::color: Index 0 out of range
QImage::color: Index 255 out of range
QImage::color: Index 255 out of range
QImage::color: Index 255 out of range
QImage::color: Index 0 out of range
KCrash: crashing.... crashRecursionCounter = 2
KCrash: Application Name = ksplash path =
Xlib: extension "RENDER" missing on display ":1.0".
Xlib: extension "RENDER" missing on display ":1.0".
Server has no DPMS extension
knotify: error while loading shared libraries: libsoundserver_idl.so.0: cannot load shared object file: No such file or direct
ory
Xlib: extension "RENDER" missing on display ":1.0".
QSocketNotifier: Multiple socket notifiers for same socket 6 and type read
Could not dlopen library knotify.la: libsoundserver_idl.so.0: cannot load shared object file: No existe el fichero o el direct
orio
knotify: error while loading shared libraries: libsoundserver_idl.so.0: cannot load shared object file: No such file or direct
ory
Xlib: extension "RENDER" missing on display ":1.0".
Could not dlopen library knotify.la: libsoundserver_idl.so.0: cannot load shared object file: No existe el fichero o el direct
orio
knotify: error while loading shared libraries: libsoundserver_idl.so.0: cannot load shared object file: No such file or direct
ory
Xlib: extension "RENDER" missing on display ":1.0".
KCrash: crashing.... crashRecursionCounter = 2
KCrash: Application Name = kwin path =
Xlib: extension "RENDER" missing on display ":1.0".
Xlib: extension "RENDER" missing on display ":1.0".
KCrash: crashing.... crashRecursionCounter = 2
KCrash: Application Name = kicker path =
Xlib: extension "RENDER" missing on display ":1.0".

What is the RENDER clause?
Where can I remove the libsoundserver_idl.so.0 clause (there is no sound on the linux box its a Dell PowerEdge 2500) ?

Re: VNC, Transparently

Anonymous's picture

The -depth clause on /etc/sysconfig/vncservers works with me!

Thanks!

Re: VNC, Transparently

Anonymous's picture

Add "-depth 24" to ARGS

ie:

ARGS="-depth 24 -geometry 800x600 -alwaysshared"

Re: VNC, Transparently

Anonymous's picture

yes, but wouldn't that [vastly] increase VNC's network load?

and if i set the 24-bit ARG you speak of, will that be overridden by the "Restrict pixels to 8-bit" option?

(i'm having the same KDE apps crashing problem running potato)

Re: VNC, Transparently

Anonymous's picture

I am using Redhat 7.1 and the vnc. I would like to access the X Desktop from a windows machine and run some java apps. I am able to do this as root but when I start vncserver as a normal user and login using vncviewer I don't get the terminal screen or the java app that I start using a startup script. Please advice. Thanking you in advance,

Shan.

VNC Transparently

Trungnd's picture

I 've just start vncserver on Linux system like this
-service vncserver start
-vncpasswd
-vncserver
after that i edit xstartup file in order to user can log to KDE enviroment like this

#!/bin/sh

# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
startkde &

And then: I reboot system
After that , I using VNC client on window platform to log on to VNCserver.
It was running.
But i can't run any terminal or any application
Is there any body can help me
Thanks

Re: apps not working

Shagie's picture

Comment these lines in your xstartup file to run terminals/apps in KDE:

#[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
#xsetroot -solid grey
#vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &

Faster VNC

Anonymous's picture

A better protocol, tight VNC, exists as well. Completely compatible with VNC (same configuration files and the same executable names).
Look at http://www.tightvnc.com.

Re: Faster VNC

Anonymous's picture

tight vnc came standard on my Mandrake 8.2 install.

Re: VNC, Transparently

jdimpson's picture

A correction to this article. In the section that titled What's Happening?, the sentence that stays "As it starts up, the VNC server reads the .xsession file in your home directory" should say ""As it starts up, the VNC server reads the .vnc/xstartup file in your home directory".

--Jeremy Impson

Re: VNC, Transparently

slimjimmonk's picture

I use another way to suspend my session. Instead of Ctl-Alt-Backspace, I choose the ``Quit viewer" from the VNC pop-up menu. This exits the viewer and returns me to the gdm logon.

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState