Linux desktops on Windows using VNC

476

Author: Rob Reilly

Need to integrate your Windows and Linux machines over a network? One tool that may help is VNC, a frame-buffer-based client/server application that lets you display desktops on remote networked machines, and which runs on all kinds of platforms, including Linux, Unix, Macs, Windows, and mainframes.

Most Linux distributions include some form of VNC. If you need to download, there are several versions to choose from, including RealVNC, TightVNC, and KDE’s Desktop Sharing, the VNC desktop server and client built into KDE.

VNC runs on all types of hardware, including laptops. I’m currently running SUSE Linux 8.2 on my puny 300MHz Pentium II no-name Taiwanese clone laptop. The VNC server that I used was SUSE’s 3.3.3r2-463 version, which came bundled on the CDs.

Before you can begin using VNC, you must set a password on the server side. You can do this and other VNC server-related tasks easily from the command line. As a regular user, in an xterm, type vncpasswd, followed by the password and the obligatory re-type. The password will be the same across multiple instances of the VNC server.

Starting the server is easy, too. In an xterm, as a regular user, type:

     vncserver

The server will start and print something like:

fig
     New 'X' desktop is curley:2

     Starting applications specified in /home/rreilly/.vnc/xstartup
     Log file is /home/rreilly/.vnc/curley:2.log

This means that there is a new desktop available to VNC clients on the client machine with a display number of 2. You need this information to connect from the client. You can also express the machine and display number as an IP address, such as 192.168.2.24:2. (You can get the server IP by logging in as root and typing ifconfig.)

Vncserver can also be used with command-line options. For example:

     vncserver -geometry 800x600 -depth 16 :4

This command starts the server and sets the screen size to 800×600 pixels with a color depth of 16 on display number 4. You can also use more complicated options, such as setting the TCP port or turning off sharing.

You can set the default desktop look and feel by editing the xstartup file in your home .vnc directory.

With the VNC server up and running, let’s turn our attention to the VNC client side.

VNC on a Windows machine

As a demonstration of how slim VNC is on system resources, I pressed a vintage 200MHz Pentium Windows 98 machine into use as a VNC client. Obviously, screen refreshes would be better with higher-powered hardware. Many factors can affect performance, including server size, network bandwidth, and the applications running.

There are at least a couple of VNC clients that you can run on Windows: TightVNC and RealVNC. I tested both and saw no real difference between the two, except for cosmetics. TightVNC has two versions, Fast Compression and Best Compression. The Best Compression had horrendously slow repaint times. RealVNC lacks a compression option. So as not to be redundant, I’ll just describe the TightVNC operation.

When you start the client software, a little window appears and asks you for the server name. After you enter it and click OK, a password box appears for you to fill in.

When I’d entered my server’s IP address and password, I was greeted with a full screen view of my laptop’s desktop, as seen in Figure 1. I clicked around and even started up the Konqueror Web browser in full-screen mode. Slashdot took a few seconds to load, but it was very readable and reasonably snappy.

TightVNC window on the Windows 98 desktop

To test multiple client connections to the VNC server, I started up the KDE Connection Sharing program on another laptop running Mepis Linux. The startup procedure on Linux was similar to starting the VNC client on Windows.

So there I was using a Linux desktop (running on my SUSE laptop) while seated at a Windows 98 machine, and at the same time my Mepis laptop simultaneously tracked my every movement of the mouse on its LCD screen.

You can click on the icon in the upper left corner of the VNC client window to bring up the program’s menu. You’ll find connection options, connection info, and the option to switch to full-screen mode. The best screen repaints seem to be with Hextile on and Allow CopyRect encoding turned off, under the connection options tab.

Similarly, with RealVNC, I turned off auto select on the colour/encoding tab and punched the Hextile radio button, to make the repaints a little faster. For really vivid colors you should use the full button in the color level section.

Browsing with VNC

If you like the VNC server and client software, you might also be interested in using VNC through a browser (Mozilla or Internet Explorer) to access a Linux desktop from a Windows machine.

Start up your browser, type in the URL of your VNC server and the port number, and away it goes, as long as you have Java loaded. If you don’t, the browser will ask you if you want to get the plug-in. Say yes and follow the directions to get it loaded.

The port number is a little tricky. The default is 5800. To use the :2 desktop from the server simply add the 2 to the 5800 number. So, my complete URL was:

     http://192.168.2.24:5802/

As you would expect, Java took a minute or two to start, and then up popped the password box.

Again, I opened the Options tab (located on a little panel at the top of the browser window). Encoding was set to Hextile. I also changed use copyrect to no and raw pixel drawing to fast.

Performance after the initial page loading was very good, with vivid colors. Figure 2 shows Konqueror running on the Linux laptop, inside the Mozilla browser on the Windows 98 machine.

Browser/Java view of the Linux desktop on Win98

Troubleshooting VNC

The main problems I’ve had with VNC are bad network connections. It’s easy to chase your tail trying to figure out what’s wrong if you are just getting started with the programs.

Always check to see that your VNC server is running. You can run ps -ax and look for a VNC-type line. Look for a line like this:

     12920 pts/6 S 1:03 Xvnc :2 -desktop X -httpd /usr/share/vnc/classes -auth /home/rreilly/.Xauthority -geometry 1020x768

The next thing to check is to ping the server from the client machine. I used:

     ping 192.168.2.24

A response with a round trip time in the 8 to 12 ms. range is great. Of course, if you don’t get any round trip data, there is a problem with your network connectivity.

Wrap-up

VNC is a practical way to work on your Linux machine while you are on a Windows box. For more of an overview of VNC, see Russell Pavlicek’s “VNC: Virtually there and back again” article. Pavlicek talks about the different versions and their features.

If you want to see VNC in action, the Melbourne Linux User Group usually runs a VNC server, along with streaming audio and IRC sessions, during its meetings, so remote members can see what’s being discussed during a presentation. Find their IRC channel and they can help you get connected.

An interesting VNC-related program is vncrecord, which records all the keystrokes you make while doing work on the desktop.

Go try the VNC server and clients for yourself. They are easy to set up and are powerful tools for the mobile IT professional.

Rob Reilly is a consultant, writer, and commentator who advises clients on business and technology projects. His Linux, portable computing, and public speaking skills-related articles regularly appear in various high-end Linux and business media outlets.