Windows terminal services in Linux with Rdesktop

Terminal Crossing


Rdesktop lets you participate in a Windows Terminal Server session from your Linux desktop.

By Markus Klimke

Christian Kowalczyk, Fotolia

The Rdesktop [1] project, launched by Matthew Chapman, is an open source client for Windows terminal servers. Rdesktop, which implements Microsoft's sparsely documented RDP protocol on Linux, adapts flexibly to available network bandwidth, giving users the same options for accessing terminal servers that Windows systems have. SeamlessRDP by Cendio [2] takes this solution one step further by giving users the ability to launch individual applications such as Word or the Microsoft Management Console on Linux.

Figure 1: Appearances can deceive: This is not a picture of a Vista system. What you see is Rdesktop displaying Windows in full screen mode on Linux.

RDP is based on the T.120/T.128 standard [3] (formerly T.SHARE) by the International Telecommunications Union (ITU [4]). Microsoft extended this protocol and introduced it to Windows NT version 4 as Windows terminal services. Windows Terminal Server gives multiple users the ability to display a remote desktop on the local machine and launch applications on the terminal server, just as with X Window. Resource-hungry Windows applications can thus run on powerful server machines instead of on the local desktop.

Besides the terminal services integrated with Windows, vendors such as Citrix [5] and NoMachine [6] offer their own terminal server solutions. Both solutions require the installation of server and client software.

If you simply need to manage one or more Windows systems remotely, you do not have to go to all this trouble: Although Microsoft charges a license fee for multi-user terminal services, two free connections are available for management work in more or less any Windows variant, whether it is a server or desktop version. That said, Windows gives you some differences between the RDP versions: Windows XP and Windows Server 2003 talk RDP5, whereas Windows Vista and the future Windows Server 2008 talk RDP6. The current version of Rdesktop is 1.5.0, which is the version used for the examples in this article.

Remote Access

To connect to a Windows server, simply launch Rdesktop with the server's DNS or public hostname as a parameter. Rdesktop will automatically choose the color depth and matching keyboard layout. Users can change these settings using command-line options. Rdesktop also accepts usernames and passwords, but consider the security implications of entering your password in the clear at the command line. A typical Rdesktop command line might look like this:

rdesktop -a 16 -x l -g 1200x900 -u Administrator Windows_Terminal_Server

The -a 16 option selects 16-bit color depth. Windows policies do not allow more color depth by default, although you can remove this restriction in the group policy for your domain. The setting is located in the Computer | Terminal Services | Rdesktop policy. Because Rdesktop will use a resolution of 800 by 600 by default, and this is likely to make it difficult to work with the remote Windows machine, it makes sense to specify a higher value with the -g parameter.

Several GUI-based front-ends, such as Grdesktop [7], TSClient [8], and KRDesktop [9], remove the need for users to type parameters at the command line. However, they do not give you the complete Rdesktop feature scope, so many system administrators prefer the console-based approach.

Slow Connections

Although network bandwidths of less than 100MBps are becoming rare, they still play an important role as redundant management lines in professional IT infrastructures. Because of low transfer rates, mechanisms that bundle as much data as possible into a network packet are just as important here as with modem or ISDN lines.

The -z Rdesktop command line parameter compresses the data as a precondition for a desktop connection over a slow network. However, use of the -x parameter in connection with the b, l, or m parameters to optimize the connection can save far more bandwidth.

-P stores frequently recurring bitmaps on your local hard disk, which can cause a delay in establishing a connection. The -b option avoids character-based operations client-side, forcing the server to update the whole screen as a bitmap.

Rdesktop uses what is known as a backing store to store screen sections that have already been rendered to accelerate screen redraws.

The -B option tells the software to use the X server's backing store instead; for this to work, you need to enable the "BackingStore" "true" option in your xorg.conf file.

Redirecting Devices

Device redirection, which gives the server machine access to your printer, serial and parallel ports, sound output, and file system, works fine with Rdesktop on Linux: The -r option, followed by disk, lptport printer, or sound, allows sharing of these resources. For example, disk:share=/home/user/share will share the directory to the right of the equals sign as share. Shares are useful if you need to install, say, a service pack on multiple Windows machines, and you have downloaded the service pack to your local client. (See also the box titled "Rdesktop Command-Line Parameters.")

Box 1: Rdesktop Command-Line Parameters

-u User: Username for Windows login.

-d Domain_Name: Authentication domain.

-s shell_application: Replace default Windows shell (Explorer.exe).

-g geometry: Window size for remote connection (width x height). The workarea parameter uses the window manager's _NET_WORKAREA value. Also, you can express the window size as a percentage of the client's screen resolution, for example 80%.

-f : Full-screen mode. Can be enabled/disabled at run time by pressing Ctrl+Alt+Enter.

-K: Keep window manager's keyboard shortcuts. By default, Rdesktop will pass all keyboard input to the Windows application if its window is active.

-r comport:Windows_port_number=Unix_device: Redirect serial port.

-r disk:name=/local/path: Share filesystem /path/on/client as name for server access. Requires Windows XP or newer.

-r lptport:Windows_port_number=Unix_device: Redirect parallel port. Bidirectional operations require Windows XP or newer.

-r printer:queue_name[=<driver>]: Redirect printer. The specified printer driver must match the driver for the local queue. Rdesktop will use the first printer specified as the default printer.

-r sound:[local|off|remote]: Redirects server sound output to the client.

SeamlessRDP

The Rdesktop -s option lets you replace the standard Windows shell (Explorer.exe) with another application. SeamlessRDP launches the GPL'd SeamlessRDP shell by Cendio on establishing a connection. To allow this to happen, the administrator of the Windows machine needs to unpack the ZIP file [2] in any directory. The following command

rdesktop -u Administrator -A -s "C:\directory_name\seamlessrdpshell.exe mmc.exe" server-address

on the Linux machine then launches mmc.exe, the Microsoft Management Console, in a separate window.

Figure 2: SeamlessRDP lets you display individual Windows applications on the Linux desktop.

As explained earlier, Rdesktop also has the ability to display an individual Windows application, rather than a full-fledged Windows desktop. To display an individual Windows application, give the Rdesktop -s option and specify the name of an application to launch on the Windows machine instead of Explorer.exe. The application that SeamlessRDP launches is the GPL-licensed SeamlessRDP shell by Cendio [2].

To install, unpack the ZIP file [10], copy the contents to a directory on the Windows system, and remember the path. Rdesktop will complete the job on Linux if you type the following:

rdesktop -u Administrator -A -s "C:\seamlessrdp\seamlessrdpshell.exe mmc.exe" server-address

The -A tells Rdesktop that this is a SeamlessRDP connection. -u Administrator gives you administrative privileges. Before the Management Console launches, the Windows login screen will appear in the Rdesktop window. In this way, you can launch any Windows executable.

MSC files that you created using the Management Console, as well as .doc files, can't be opened directly by reference to the document type and application. If the .exe file is not in the Windows path for executables, you need to specify the full pathname. Unlike Windows, it is important to use upper case for drive letters. If you are unable to launch the SeamlessRDP shell, the connection will default to normal desktop mode. When accessing Windows XP, note that fast user switching and the welcome screen are active on the Windows page.

Figure 3: RDP is an extension of the International TelecommunicationUnion's T.128 (T.share) Multipoint Application Sharing protocol.

Replaces Sneakers

Rdesktop with or without SeamlessRDP can facilitate the administration of Windows machines in heterogeneous environments: It is easy to share files stored centrally on the client for tasks on multiple servers. Data exchanges via the clipboard work well across platform boundaries as well. If you like, you can redirect your printer or sound output, with the restriction that only two RDP connections are available simultaneously. Rdesktop will display any Windows application on Linux without impairing its functionality, although you can expect occasional display glitches in single-window mode when using SeamlessRDP.

INFO
[1] Rdesktop: http://www.rdesktop.org/
[2] SeamlessRDP by Cendio: http://www.cendio.com/seamlessrdp/
[3] NetMeeting 3.0 Resource Kit, T.120 standard: http://www.microsoft.com/technet/archive/netmeeting/reskit/netmtg3/part3/chaptr10.mspx?mfr=true
[4] International Telecommunication Union: http://www.itu.int
[5] Citrix Terminal Server: http://www.citrix.com
[6] NX by NoMachine: http://www.nomachine.com/
[7] Grdesktop: http://savannah.nongnu.org/projects/grdesktop
[8] TSClient: http://freshmeat.net/projects/tsclient/
[9] KRDesktop: http://krdesktop.sourceforge.net/
[10] SeamlessRDP download: http://www.cendio.com/seamlessrdp/?searchterm=SeamlessRDP