open.itworld.com
  Search  
Security Home Page Security Webcasts Security White Papers Security Newsletters Security News Open Topics Careers ITworld Voices ITwhirled The Security site of ITworld.com

Unix Tip: Using VNC to access remote systems

ITworld 12/12/2007

Sandra Henry-Stocker, ITworld.com

Send in your Unix questions today! | See additional Unix tips and tricks.

Similar to Remote Desktop, VNC (Virtual Network Computing) provides its users with access to remote systems' displays from their desks.

VNC is platform-independent. You can have a viewer on almost any type of system and a server on almost any type of system. You might control your Solaris system from a Windows desktop, your Windows system from your Linux desktop and so on. Plus, an added bonus is that many people can connect to the same server at the same time.

On this topic

VNC works without requiring an X Windows software installation on the client. Instead of using X, it makes use of the RFB (remote framebuffer) protocol to control the remote system, transmitting keyboard and mouse events with primitive commands and relaying screen updates. It can be a bit confusing at first to grasp how VNC relates (and doesn't) to X Windows, but let's give it a try.

When using X, the server is the system operating the display (in other words, your monitor and keyboard). X clients are whatever programs happen to be running and contributing their output to that display. With VNC, on the other hand, it is the clients that operate the display. Your desktop runs the client software. The server is telling it what to display. This isn't just a difference in terminology; it's a difference in how the underlying protocols work. Think of it this way: An X display is created on the system that is acting as a server and that display is then transmitted to the client using VNC. More succinctly, the server shares its screen, the client provides a viewing surface and the protocol, though very primitive, transmits user actions and screen updates between the two.

There are a number of implementations of VNC. RealVNC is one of the most popular and better known and offers a free version that has fewer features than the commercial products but still supports Windows and Unix. There's also TightVNC, UltraVNC and even Chicken of the VNC for you tuna fans.

To start a VNC session, you log in to the server and issue the command "vncserver". This (vncserver) is a Perl script that starts Xvnc which, in turn, is both an X server and a VNC server.

To use VNC on Solaris, you will need xauth (/usr/openwin/bin/xauth) on your path. You then start vncserver by typing "vncserver" or, including a specific display, "vncserver :2" (for desktop #2). To then bring the virtual desktop on your real desktop, use the system name, (optional) port number and the desktop number when you start your client. For example, you might specify "10.1.2.3:5902:2" or just "10.1.2.3:2".

The first time you invoke vncserver, you will be asked to provide a password which will be used to authenticate you:

  $ vncserver

You will require a password to access your desktops.

Password:
Verify:

You can then issue the command again to start your first server:

  $ vncserver
  xauth: creating new authority file /home/shs/.Xauthority
  
New 'X' desktop is boson:1

Creating default startup script /home/stockers/.vnc/xstartup
Starting applications specified in /homes/stockers/.vnc/xstartup
Log file is /home/stockers/.vnc/boson:1.log

You can then start the client process on your local system. The server sets up a .vnc directory in your home. This is where your log, your passwd file, your pid file and an xstartup file establishing your initial X settings are stored.

If you close your client window, your server process will continue running and you can reconnect whenever you want. To shut down the server process, use the vncserver command with the -kill argument followed by the number of your display (e.g., vncserver -kill :2).

The X window manager will start whenever you start a server. By default, this will be twm. I installed blackbox as well and updated my ~/.vnc/xstartup file to make use of it. Other window managers such as blackbox will generally give you a nicer looking display than the basic twm, including features such as multiple screens.

  #!/bin/sh

[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
  xsetroot -solid blue
  vncconfig -iconic &
  xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
  bsetbg -t /home/shs/.blackbox/backgrounds/cleo_512.tif
  /usr/local/bin/blackbox &

With my use of blackbox, I also have a .blackboxrc file which I can use to customize the menu that appears on my virtual desktop.

If you issue the vncserver command and a server doesn't start, check your log file. If you notice error messages complaining that you failed to establish a connection to a listener, make sure your /tmp/.X11-unix directory is set to 777. You should only have to do this once per system.

VNS servers listen on ports 5900, 5901, 5902 and so on. Its Java viewers, if available, will use 5800, 5801 etc.

From the point of view of the server, your display is unix:1.0, unix:2.0 etc. depending on the display assigned when you started the server. Remember this isn't X, so you don't want DISPLAY set to the display on your local system.

A Solaris VNC package, SFWvnc, is available on the supplemental software CD that ships with the OS and installs in /opt/sfw/bin. Setting up VNC on my Solaris server didn't take very much time at all. I installed the package, fixed the permissions on the /tmp/.x11-unix directory, assigned myself a password (using the vncpasswd or waiting to be prompted) and customized my ~/.vnc/xstartup file.

Some versions of VNC are significantly less secure than ssh because passwords, not exactly sent in the clear, are far more crackable than we'd like. Others (such as the non-free versions of RealVNC) take security very seriously and provide 2048-bit RSA authentication and session encryption.

If you only work on the command line, access to a remote server's display might not have much appeal, but VNC tools can be an inexpensive (even free) and very functional alternative to adding an X server to your desktop and provide a lot of flexibility in the heterogenous network.

Sandra Henry-Stocker has been administering Unix systems for more than 18 years. She describes herself as "USL" (Unix as a second language) but remembers enough English to write books and buy groceries. She currently works for TeleCommunication Systems, a wireless communications company, in Annapolis, Maryland, where no one else necessarily shares any of her opinions. She lives with her second family on a small farm on Maryland's Eastern Shore. Send comments and suggestions to bugfarm@gmail.com.




Sponsored Links

Sign up for a Microsoft Dynamics® CRM WEBCAST
Hear globally recognized leaders in customer strategy discuss the importance and evolution of CRM.
CAPTURE Quad-Core Performance
Check Out The Latest In Capturing The Value Of Xeon® Quad-Core Servers For Your Business.
IP Networks Boost Secure Health Communications
AT&T provides secure communication to keep health care moving forward.
Protecting the Enterprise Network Through Web Security
New focus is being placed on securing Web-based threats.
FREE Application Discovery Tool from Sophos
Scan your network for VoIP, IM, games and other potentially unwanted applications.
» Buy a link now

Advertisements
Sponsored links
Bring harmony to your mix of UNIX-Linux-Windows computing environments
Top 5 Reasons to Combine App Performance and Security
KODAK i1400 Series Scanners stand up to the challenge
Locate Hidden Software on business PCs with this free tool
 Home   Open source  Operating systems  Unix
www.itworld.com    open.itworld.com     security.itworld.com     smallbusiness.itworld.com
storage.itworld.com     utilitycomputing.itworld.com     wireless.itworld.com

 
Contact Us   About Us   Privacy Policy    Terms of Service   Reprints  

CIO   Computerworld   CSO   GamePro   Games.net   IDG Connect   IDG World Expo   Infoworld   ITworld   JavaWorld   LinuxWorld  MacUser   Macworld   Network World   PC World   Playlist  

Copyright © Computerworld, Inc. All rights reserved

Reproduction in whole or in part in any form or medium without express written permission of Computerworld Inc. is prohibited. Computerworld and Computerworld.com and the respective logos are trademarks of International Data Group Inc.