Have
you ever wanted to run a graphical application securely and
remotely with Linux or Unix? How about from a Microsoft Windows
PC to a Linux/UNIX host? This tutorial is about X,
SSH2, and window managers. This is not about VNC,
a completely different tool which merits its own tutorial. It is not
about thin-client computing using X, another huge topic. The
focus of this article is on how you, as a system administrator or power
user, can use X over SSH to get work done. As a special bonus, most
GNU/Linux distributions already contain everything you need,
so you will probably not need to install anything or modify any configuration
files in order to use these tools.
What is the X Window System ?
It is a system that allows graphical applications to be used on Unix-like operating systems instead of text-only applications. It is the foundation for Linux and Unix GUIs (Graphical User Interfaces). X development began at MIT in 1984, with assistance from IBM and DEC (later Sun, HP, Apollo, and Tektronix). It has the following features:
- client/server
- network aware
- hardware independent
- vendor independent
- allows interoperability between heterogeneous systems
X (current version, X11) is defined by standards and contains standardized protocols. The X server is a process that runs on a computer with a bitmapped display, a keyboard, and a mouse. X clients are programs that send commands to open windows and draw in those windows. Although the client and server are typically on the same machine, they can also run on different machines over a TCP/IP network. X typically uses TCP ports 6000 - 6063.
For example, I frequently run X over my private LAN from a laptop to my server. I also routinely use X over SSH to run GUI apps back in the United States while I am in Taiwan! The "networkability" of X allows a powerful central server to run graphical applications or even entire GUI desktops for hundreds of less powerful machines, such as X terminals or thin-clients. It is also quite common to run X servers on MS Windows PCs in order to access graphical applications on more powerful Unix or Linux machines.
There are some problems with classic X networking, though. It can be a difficult to setup, has security issues, and may not work well over low-bandwidth WAN links. It can also be broken by firewalling and NAT. These issues typically restrict classic X networking to private LANs.
The X11R6-compliant X software I will be talking about in this tutorial is XFree86, an Open Source implementation that is usually seen on Linux and the various BSDs. I have also been able to run X client/server sessions between Solaris and Solaris, and Linux and Solaris, even though Solaris 8 does not use XFree86.
For more information on X, you may want to go right to the official website: www.x.org
What is SSH ?
SSH, or the Secure Shell is the "Swiss Army knife" of host-to-host networking. It allows secure (encrypted and authenticated) connections between any two devices running SSH. These connections may include terminal (CLI) sessions, file transfers, TCP port forwarding, or X Window System forwarding. SSH supports a wide variety of encryption algorithms, including AES-256 and 3DES. It supports various MAC algorithms, and it can use public-key cryptography for authentication or the traditional username/password. The good news is that SSH does not cost anything on the client or server side, although there are some nice SSH packages for MS Windows that require you to purchase commercial licenses.
X over SSH solves some of the problems inherent to classic X networking. For example, SSH can tunnel X11 traffic through firewalls and NAT, and the X configuration for the session is taken care of automatically. It will also handle compression for low-bandwidth links.
For more info on SSH, check out the official OpenSSH website .
What is a Window Manager ?
A Window Manager is a piece of software that manages windows, allowing the windows to be opened, closed, re-sized, and moved. It is also capable of presenting menus and options to the user. It controls the look and feel of the user's GUI. With Linux or BSD, you have choices. You are free to select any number of window managers, ranging from lean-and-mean simple ones (low memory and CPU consumption), to feature-packed large ones. There are approximately 17 "mainstream" window managers, and at least 70 others.
Here is a short list of some of the more popular ones: fvwm2, twm, mwm, wm2, AfterStep, Enlightenment, WindowMaker, IceWM, Sawfish, Blackbox, Fluxbox, and MetaCity. For a really nice website that lists them all, try www.plig.org/xwinman/ .
What is a Desktop Environment ?
A desktop environment (DE) usually rides on top of a Window Manager and adds many features, including panels, status bars, drag-and-drop capabilities, and a suite of integrated applications and tools. In fact, user opinions on operating systems are typically based on one thing: the Desktop Environment. Of course, the DE is only a small part of an OS, and in Linux and Unix systems, the Window Manager and/or DE can be replaced or highly customized without violating any end-user licensing agreements.
The most popular Desktop Environments for Unix/Linux are: GNOME, KDE, CDE, and XFce. Of couse, there are others.
1. X over SSH on a LAN
2. X over SSH on a long-distance WAN
3. Desktop Environment over SSH
4. X over SSH from a Win32 PC to a Linux host
Note: I was able to use FreeBSD
on RAT's hardware to test some of the X over SSH scenarios. LAPTOP
to BSD-RAT worked fine.
Screenshot of X over SSH sessions on LAN (Click to Enlarge)
Screenshot of
X over SSH sessions over long distance and low-bandwidth WAN link
Individual X apps running on a Windows XP desktop
"Multiple" window mode.
Uses local (X-ThinPro) window manager
X-ThinPro X server setup
window on Windows XP
WindowMaker desktop running
on Windows XP desktop
Motif Window Manager X
applications in "Single" window mode
Full remote KDE desktop
running on Windows XP desktop
X over SSH on Win32 with PuTTY (note the
PuTTY port forwarding configuration window)| Window Manager /
Desktop Env. |
# of X Windows open |
% memory used by
GUI processes |
CPU Load |
Total Number of GUI-related
processes |
Notes and comments |
| mwm |
3 |
2.7% |
< 2% |
3 |
Fast. Exits cleanly. |
| twm |
3 |
2.3% |
< 2 % |
3 |
Fast. Exits cleanly. Less intuitive
than mwm. |
| fvwm2 |
9 |
5.7% |
< 2 % |
9 |
Longer load time compared with mwm
and twm. Exits cleanly. |
| wmaker |
3 |
2.6% |
< 2 % |
3 |
Relatively fast, looks nice, very
customizable. Exits cleanly. |
| KDE |
14 |
81.2% |
< 3 % |
20 |
Comes up slowly. Exits cleanly.
Fairly responsive on LAN, complete DE. |
| Gnome |
13 |
41.5% |
< 3 % |
16 |
Comes up slowly. DOES NOT EXIT
cleanly (left 2 windows and 4 processes open that had to be killed
manually). Fairly responsive on LAN. Looks nice, complete
DE. |
| blackbox |
3 |
2.5% |
< 2 % |
3 |
Slower to load than mwm or twm, but
faster than the others. Fast, responsive, uncluttered. Customizable.
Exits cleanly. |
| X Client (Program)
|
Avg. BW Util. (bi-directional) |
Packets Per Sec. (bi-directional) |
Avg. Packet Size |
Comments and Notes |
| xdaliclock -cycle (1) |
162 Kbps |
77 pps |
262 bytes |
|
| xdaliclock w/SSH compression (2) |
87 Kbps |
75 pps |
145 bytes |
Used the -C option in the SSH command |
| mwm window reposition (3) |
4.26 Mbps |
3959 pps |
135 bytes |
Constant window movement. See
note. |
| mwm window repos. w/compression |
1.57 Mbps |
1825 pps |
107 bytes |
Constant window movement w/SSH compress. |
| xclock -update 1 (large) (4) |
3 Kbps |
2.1 pps |
155 bytes |
Resized to 1/4 of screen |
| xclock (large) w/compression (5) |
2 Kbps |
2.1 pps |
92 bytes |
Same as above, with -C option in SSH
cmd. |
| kasteroids arcade game (6) |
1.1 Mbps |
163 pps |
843 bytes |
Game was fairly responsive |
| kasteroids game with compression |
168 Kbps |
61 pps |
346 bytes |
Game was fairly responsive |
| KDE session startup (7) |
2.35 Mbps |
485 pps |
606 bytes |
Opened 12 windows |
| KDE session startup w/compression (8) |
249 Kbps |
152 pps |
205 bytes |
Opened 12 windows, took longer to load |
| KDE session w/lots of activity (9) |
865 Kbps |
236 pps |
457 bytes |
Desktop was responsive. See note. |
| KDE session w/compression |
257 Kbps |
178 pps |
180 bytes |
Desktop was responsive |
| Creating a text file in Pico in an xterm
(10) |
13 Kbps |
13.6 pps |
123 bytes |
Typical text editor session |
| Abiword word processor (11) |
171 Kbps |
68.4 pps |
312 bytes |
Worked fine. See note. |
| Abiword w/compression |
48 Kbps |
50.3 pps |
120 bytes |
|
| Mozilla browser window scrolling
(12) |
2.31 Mbps |
410 pps |
703 bytes |
Constant scrolling of web page up &
down |
| Mozilla window scrolling w/compression |
537 Kbps |
222 pps |
302 bytes |
Save as above, with -C option in SSH
cmd. |