Open Source

Configure IT Quick: Use rdesktop to administer Windows from Linux

Use this tutorial to install and use rdesktop to allow a Linux system to access Windows Terminal Services.


Working in a cross-platform data center is now the rule rather than the exception for the vast majority of administrators, as both Windows and Linux have made inroads into organizations around the world. But because the two operating systems are so different, allowing fluid communication between them can be a challenge. That's where rdesktop comes in.

Rdesktop is a Linux implementation of Remote Display Protocol (RDP). Windows uses RDP to connect to other Windows computers via Terminal Services. With rdesktop, you can open a remote control session on a Windows NT/2000/XP machine from a Linux box.

Rdesktop lets you pull up a Windows desktop remotely and perform any function just as if you were sitting directly in front of it. For instance, you might set up a Web page on a remote Windows 2000 server or add a user to your NT domain in the data center. Rdesktop is like PCAnywhere, but with total control of the remote desktop and much better performance.

Because it's released under the GPL open source license, rdesktop has no licensing fees on the client side. But you still need to keep track of how many Terminal Services client licenses are used from your terminal server.

Getting and installing rdesktop
Rdesktop is widely available and is included in packages for most major distributions, such as Mandrake, Red Hat, and Debian. As always, your best bet is to use your distribution’s package manager to find and install rdesktop.

You can obtain and install the source code on most any Linux system. Special GUIs are available for rdesktop. For instance, Mandrake offers RFBdrake, which allows you to graphically start rdesktop sessions. RFBdrake lets you connect Linux machines when run in server mode, as well.

The rdesktop program is available for free at rdesktop.org. The source package is only about 80 KB, so it makes for a quick download.

Once you have rdesktop on your system, you just need to uncompress and install the software. Running the following commands should be enough to get you started:
tar xpfz rdesktop-1.1.0.tar.gz
cd rdesktop-1.1.0
./configure
make
make install

This point of the installation is a good time to configure any firewalls that may be in the path of communication. By default, rdesktop will use TCP port 3389 to connect to a Windows machine. You will need to open this port, but limiting access to specific IP addresses or subnets is a good idea. Since this port allows remote access to your server, you'll want to keep it secured. Always make sure that you have rdesktop prompt for a password, especially if the system in question is connected to the Internet.

Using rdesktop
Rdesktop is easy to use. Let’s say you want to log in to the local Exchange server as administrator from your Linux workstation. You would simply type something similar to:
rdesktop -u administrator -g 1024x768+0+0 ex-mail-01.example.com

As you can see, we call the  rdesktop command and pass it the username administrator. Then, we specify the desktop geometry to be 1024x768, starting at 0 x and y offsets. You can change this to meet your needs. Next is the hostname of the server we want to connect to, in this case ex-mail-01.example.com. For easier access, you can create a little script or an alias for each remote Windows machine you need to access.

Here are some of the other options you can include:
 -u: username
 -d: domain
 -s: shell
 -c: working directory
 -p: password (auto logon)
 -n: client hostname
 -k: keyboard layout (hex)
 -g: desktop geometry (WxH)
 -f: full-screen mode
 -b: force bitmap updates
 -e: disable encryption (French TS)
 -m: do not send motion events
 -l: do not request license

It's also important to remember that rdesktop requires Terminal Services to be running on any machine you need to connect to. Make sure Remote Desktop is enabled on your Windows host if you experience any problems connecting. Again, you may need to check on licensing to ensure that your server will allow the necessary number of connections. Remember that more than one connection can be made to a Terminal Services server. Determine your needs and make sure that your Windows licenses match up.

Rdesktop is capable of operating in full screen or windowed mode. Full screen mode is certainly nice, but you may find better performance operating in a window. In addition, the window approach lets you open multiple connections to remote desktops at the same time. This enables you to connect to a number of different systems simultaneously and is great for troubleshooting cross-platform issues. Whether you're dealing with network connectivity or software development, this type of access can be a tremendous advantage.

Summary
Rdesktop lets a Linux system participate in the remote Windows administration that is available with Terminal Services, allowing for the use of both operating systems simultaneously. This can streamline your administration and development chores, making your job a whole lot easier.

Editor's Picks