VNC, Transparently

Secure, transparent and ubiquitous desktops with VNC and OpenSSH, Part 1 of 2.

This two-part series presents a novel way to set up a VNC-based X Window System desktop for your Linux system. By the end of this two-part series, you'll have a configuration that allows users to log in to their X-Window desktop (running GNOME, KDE or other preferred window manager environment) via a display manager (like GDM, KDM or XDM). More importantly, the user will have secure access to the same desktop in the same state from the workstation console and anywhere else on a network.

Typically, a workstation system runs a display manager. In this article we refer to such applications as XDM, GDM (GNOME Display Manager) or KDM (KDE Display Manager) generically as display managers. A display manager provides a graphical login prompt for the user. When a user logs in, the display manager starts the appropriate window manager (such as fvwm2, GNOME or KDE). From the window manager, the user can run whichever applications he or she wishes. When the user logs out, applications are closed, the window manager exits and the display manager reappears, ready to allow another user to log in. If the same user logs in again, the display manager starts the window manager anew, and all the applications must be restarted. This is how traditional X Window System desktops work. We refer to such a desktop session as an X desktop. We also say that when a user is using the keyboard and monitor of the workstation, he or she is logging in to the console. This is as opposed to connecting via the network.

Figure 1. A Display Manager

In the Linux Journal article titled “Virtual Network Computing” by Choong Ng [available at www.linuxjournal.com ], we learned how to set up VNC in order to allow stateful access to a desktop from any computer on the network. By stateful, I mean that when a user is not connected to the desktop, the desktop does not terminate but remains waiting for a user to reconnect. When the user connects to the VNC server using a VNC client, every window is in the place where it was last left, every application is still in the same state as when last used, and every opened file remains opened in the same position. The nature of the VNC server, which controls the window manager and the applications, permits this.

Therefore, any computer on the network can run a VNC client (such as vncviewer) to connect to the workstation and display the desktop. We even could run the VNC client on the workstation on which the VNC server is running. We refer to such desktop sessions as VNC desktops, and we refer to the workstation where we run the VNC server (and its window manager) as the VNC workstation.

There is one problem with VNC desktops. Suppose you want to log in to the console of the VNC workstation. Your VNC desktop is running on this workstation as well, the same one you connect to from many different computers on the network. You want to continue to have access to the VNC desktop via the network. At the same time, when you log on to the console via a display manager, you want to see the same desktop you see when you connect via VNC. But if you log in to the workstation via the display manager, it will start a new window manager. Basically, you have started a new X desktop, one which is independent of the VNC desktop, already running on this workstation.

If you want to connect to the VNC desktop, you must run a VNC client, such as vncviewer. This is awkward due to the fact that one window of the X-based desktop is itself another desktop (the VNC desktop). Keeping track of the many levels of redirection can be troublesome. Besides being confusing, due to ambiguity as to what desktop the user is actually using, it also is inefficient as it requires two window managers to run concurrently, when only one is needed.

Figure 2. Screenshot of an X Desktop Running vncviewer, Displaying a VNC Desktop

This article explains how to configure an X server, display manager and a VNC server so that the desktop one sees when logging in to the display manager is the VNC desktop, with no second window manager and with all files and applications in the same state as they were last left.

Prerequisites

The scheme we discuss can work on any Linux distribution. It requires a working X server, a display manager and VNC. I checked for these packages with this command:

rpm -q XFree86 vnc XFree86-xdm kdebase gdm

It is only necessary to have either XFree86-xdm kdebase or gdm installed. I should note that all the configuration file locations discussed in this article are as shipped with Red Hat 7.1. It is possible to configure any Linux system to allow transparent VNC desktops, but you may have to download software or locate configuration files if they are in different locations.

Whatever display manager you prefer, it should start at boot time. This is usually accomplished with a line in /etc/inittab similar to this:

x:5:respawn:/etc/X11/prefdm -nodaemon

prefdm is usually a copy of a link to whatever display manager you prefer. X and your preferred display manager must be up and running.

______________________

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.

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix