Software Provides ‘Remote’ Possibilities

Edit: I still use these tools. Although I cannot remember the last time I ran telnet.

Originally posted June 2004 by IBM Systems Magazine

Have you ever wanted to remotely control your Windows* machine from a machine running AIX* or Linux while you were working on the raised floor? Have you ever started a long-running job from your office and wanted to disconnect and reconnect from home or another location? Have you ever rebooted your machine after a visit from the “blue screen of death”? Did the reboot interrupt your Telnet or Secure Shell (SSH) session, requiring you to log back and start over again? Have you ever wanted to share your desktop with another user for training or debugging purposes?

If you answered yes to any of these questions, then Virtual Network Computing (VNC) and screen are two useful tools worth investigating.

VNC Benefits

Developed by AT&T, VNC is currently supported by the original authors along with other groups that have modified the original code. Realvnc, tridiavnc and tightvnc are all different versions that interoperate seamlessly.

VNC has cross-platform capabilities. For example, a desktop running on a Linux machine can be displayed on a Windows PC or a Solaris* machine. The Java* viewer allows desktops to be viewed with any Java-capable browser. With the Windows server, users can view the desktop of a remote Windows machine on any of these platforms using the same viewer.

This free tool is quick to download–the Java viewer is less than 100K. The AIX* toolbox for Linux applications also has a copy of VNC.

VNC is comparable to pcAnywhere or other widely used remote-control software. VNC’s power is in the number of OSs that it can allow to interoperate. AIX controlling Linux, Linux controlling Windows, Windows controlling them both–these are just some of the possibilities.

After loading VNC with smitty, you can start it by running vncserver on the command line. I recommend creating a separate user that hasn’t previously logged into an X session; I’ve seen strange behavior when using the same user ID to start a normal X and VNC session.

vncserver twice prompts you for the same password. This information is stored in ~/.vnc/passwd and can be changed with the vncpasswd command. (Note: This directory also contains the xstartup configuration file, along with some log files that show the times and IP addresses of the clients that have connected to vncserver.) Each time you run vncserver, you’ll have another virtual X desktop. (The first session runs on :1, the second on :2, etc.)

Verify that VNC is running with the ps -ef | grep vnc command (you should see Xvnc running). Connect to your server from your client machine, then run vncviewer. When prompted for the server name, enter either the IP address or the host name, followed by the session number you’re connecting to. VNC Web sites usually use snoopy:1 as a sample host name. You should then be prompted for the password you set up earlier.

At this point you should see an X desktop. The settings and version (CDE, KDE, etc.) can all be specified in ~/.vnc/xstartup. To allow others to view this session, select the shared session option from the command line or the shared session setting from the GUI if your viewer is running in Windows. Once two or more users have connected to the vncserver, you can share the session, unless you select the “view only” option when connecting.

Much of this information applies when running vncserver on Windows. Once you download the installer, install the service and set up a password, you should be able to connect to your Windows machine by running vncviewer on your AIX machine. When you connect to your Windows machine, you don’t need to specify any display numbers after the host name, as there’s only one screen that you can connect to on a Windows machine.

This is a powerful tool when team members are working remotely and are having trouble explaining to you what they’re seeing. Once you fire up a VNC session, the problem is usually apparent. It’s also a great tool to install applications that require X when nobody feels like walking out to a raised floor or when the machine is running headless and nobody wants to hook up a monitor to it.

The real power comes when you close down vncviewer and then run it again from another location. You’ll be connected right where you left off–assuming the machine hasn’t been rebooted and no one’s stopped the vncserver process. When it’s time to stop the process, run vncserver -kill :X (X is the session number you’re running for your individual situation).

The Power of Screen

Another useful tool included with the toolbox CD is screen, which allows a physical terminal to handle several processes, typically interactive shells. After loading screen with smitty, enter “screen” on the command line. You’ll see copyright information; hit “space” or “enter” to proceed. You’ll then see a typical command prompt.

To get started, vi a file, or read a manual page. When you need another command line, simply enter “ctl-a c” to create another session. You’ll be greeted with another prompt. You can continue to create several virtual sessions and toggle between them by entering “ctl-a space.” Entering “ctl-a 1” returns you to the first screen, and “ctl-a 2” to the second, etc. To list all of your windows, enter “ctl-a w.” This displays all of the key bindings that are possible in screen. If you need to detach from your session, enter “ctl-a d.” If you’re on another machine and want to attach to a screen running elsewhere, run screen -d (to detach) and screen -r (to reattach).

Power Combo

When I combine VNC and screen, I can use vncviewer to connect to my vncserver, which is running an xterm that’s running screen. My xterm takes up a small amount of real estate on the desktop, and I can quickly and efficiently move between my virtual command lines. This allows me to remain logged into multiple machines and quickly and easily switch back and forth. I also can easily cut and paste between OSs–cutting from AIX and pasting into an e-mail client running on Windows or taking information from Windows and pasting it into my vncsession.

VNC and screen are a powerful combination. With these tools, you can drop what you’re doing (or get dropped, in the case of a network or OS outage), go to another location and pick up where you left off. It’s a handy way to work.