Wednesday, July 2, 2008

Fixing rdp MIME type in Ubuntu Linux

If you've ever been presented with the problem of downloading a dynamically generated (or even static) rdp (Remote Desktop) file from within Firefox in Linux and you were optimistically expecting Firefox to recognize it and open it in some graphical interface like tsclient, you were probably sorely disappointed - you might have gotten a message like -

You have chosen to open
example.rdp
Which is a: BIN file

In this instance, you are only granted the option to Save the file to your computer.

To fix this, you need to configure Linux to automatically recognize this MIME type so that Firefox recognizes the file type as something besides binary (for some reason you can't directly add the recognition in Firefox without extensions).

To do this, you need to add the rdp MIME info into the file /etc/mime.types. Run the following two commands to quickly achieve this -

sudo -i
echo "application/x-rdp rdp" >> /etc/mime.types

This simply appends the rdp MIME info to the file.

Trying download a rdp file from Firefox now (you don't need to restart it). When the Save dialog pops up (and actually recongnizes the file type!), press the "Browse..." button to open the Application Helper selection dialog.

In the resulting window, locate the "Location" bar and type /usr/bin/tsclient (for example, if you have this installed). Press "Open" to continue. Firefox should now associate .rdp files with tsclient. Press "OK" on the open dialog to proceed.

The Terminal Services Client GUI will open. You may wish to change the various options using the tabular interface provided. This application is richer than the built in Windows Terminal Services client itself!

The next time you click on a n RDP file, Firefox should remember the association and ask you if you want to open the file in tsclient. If the "Open with" field in Firefox's Open dialog on attempts subsequent to this tutorial is blank, press "OK" regardless. tsclient should still launch.

Side note: to use tsclient, you need the packages

* tsclient
* rdesktop

So just

sudo apt-get install rdesktop tsclient