Saturday, November 2, 2013

Remote Desktop Connection from Ubuntu

I have been enjoying Ubuntu Linux now since 2008.  Like many, I didn't see it as a viable replacement for Windows as I still require the suite of MS Office programs in order to functionally collaborate with colleagues.  As of 2011, I acquired a netbook which came with Windows 7, but was far to puny to run this OS properly, let alone drive normal programs once it came up.  Before long, I ditched Windows from this machine in favor of Ubuntu (11.04 at the time, now using 13.10).  This isn't a super laptop, far from it, but it is nice to know there is an OS I can handle with my ultra portable, bombproof netbook.  The thing has a 32GB SSD, 2GB SDRAM, wifi, and a 8.9" screen.  I used the xrandr command to build a short script to modify the lame 1280x600 native resolution of the screen to a more comfortable 1368x768, and with Libre 4.1 and access to the offerings of Google Drive, I am more compatible than ever with my Windows/Mac-loving colleagues.  And still, I can't shake Windows as I have several machines I use at work.

Until an Ubuntu edition of MS Office is available (ever?), I probably will never get away from Windows, but today I found one more reason to need Windows even less.  I was bouncing from computer to computer today taking data from various places and consolidating everything in Google Drive spreadsheets.  Once collated, I will then need to send my data to my on-campus Windows image where certain statistical packages reside (JMP, SAS).  I was busy all day with lab work and lamenting that I was going to have to come back in tomorrow to do this work, or else stay very late.  If only I could run my stats from my couch...

This is when I discovered rdesktop, an easy to use client for connecting to a Windows Remote Desktop Connection from an Ubuntu computer.  From Ubuntu, it is easy to install (probably in the software center too):

sudo apt-get install rdesktop

It is a small application and installs quickly.  You are almost done...

From the terminal (doesn't come up in the dash), type

rdesktop servername

(for me, rdesktop vlab.nau.edu)

You should be at your familiar login screen.  For other NAU users, you will need to click the "other user" button and change your domain (eg NAU\username) for login.  However, the native rdesktop window is uncomfortably small, and for some reason, window resizing is not an option.  Fortunately you can use the -g option to set a specific resolution (say, -g 800X600) or a percentage of your screen size.  I like the percent option and found 90% to work best in most cases (with the scaling, a portion of your window can protrude into neighboring workspaces at >95%).  So, now I login as follows:

rdesktop vlab.nau.edu -g 90%

But that is too much to type, so I wrote a little one line script to fill in the details for me.  In my local scripts directory I did the following:

nano vlab

This puts me into the text editor nano and starts me editing the new file called vlab.

Add the following text to the text editor:

     #!/bin/bash

     rdesktop vlab.nau.edu -g 90%

Hit ctrlX to exit nano, saving as you go.

Change the permissions of the file:

sudo chmod a+x vlab

Test your script locally:

./vlab

If it works, copy the script to your bin directory so it will be called no matter your working directory:

sudo cp vlab /bin/

That's it.  Now I can go home and run my stats, and all I have to do to get the thing running is open a terminal and type:

vlab

Best of all, I can now access a Windows computer running remotely from my Ubuntu Linux netbook, giving me one less reason to need/desire Windows on my portable computer.  Of course someday I will graduate, but that also means I could purchase a competent desktop computer in the future, keep it at work (or at home if workplace firewalls are too cumbersome), and access all my Windows needs from elsewhere, and negate any need to maintain synced cloud accounts (Dropbox, Ubuntu One etc) for my workplace documents.

Happy remote desktoping, Ubuntuers!