Connect to a remote virtual machine with rdesktop
VirtualBox is an incredibly useful tool. You can run different OSes for testing purposes, you can set up servers on machine that wouldn't normal act as servers, the sky seems to be the limit. And VirtualBox is an easy tool to use.
One of the really cool aspects of VirtualBox is that it can also work as a virtual machine server. With that you can run an instance of a virtual machine from a remote location. Of course you have to have the piece of software to connect to VirtualBox. On Linux one very handy tool for that is rdesktop. In this article I am going to show you how to connect to a VirtualBox machine using rdesktop.
So far I have covered VirtualDesk fairly extensively so far. The VirtualBox "cannon" includes:
- Installing and configuraing VirtualBox for virtual OSes.
- Installing Windows XP as a virtual machine in VirtualBox.
- Install Guest Additions for a better VirtualBox experience.
- A new way of thinking, thanks for virtual machines.
- Install VirtualBox Guest Additions in Windows 7.
- Install VirtualBox with USB support.
Before you read this particular article, you might want to go through the above series so you have a better understanding of VirtualBox.
Configuring your virtual machine
Before you even try to connect to a virtual machine (with any software) you first have to set up your virtual machine so that it will allow connections to be made. VirtualBox uses the VRDP protocol for remote connections. What you need to do is go into the settings of the virtual machine and enable this. NOTE: You have to do this on a VM by VM basis. Just because you enable VRDP on one virtual machine does not mean it will be enabled on all VMs.
Let's work with a Windows 7 virtual machine. Windows 7 (or Vista) is a special instance because you have to actually enable remote connections within the operating system as well as within VirtualBox. With Windows XP or most instances of Linux, you will not have to do anything beyond enabling VRDP in VirtualBox.
To enable VRDP open up VirtualBox and click on the virtual machine you want to connect to. Now click the Settings button. NOTE: If the settings button is grayed out you need to start that virtual machine and then power it off. If you just save the state of the virtual machine you can not change the settings.
Once inside the settings window click on the Remote Desktop "tab" (see Figure 1).
In this section you will need to click the checkbox for "Enable VRDP Server". Once that is checked you can configure the options to suit your needs (the defaults work fine for Windows 7) and then click OK when you are finished.
Now it's time to boot up your Windows 7 virtual machine. When Windows 7 is up and running click on the Start menu and enter "Remote" (no quotes) in the Search area. You will see a few entries in the results. Of those entries clickÂ "Allow remote access to your computer".Â When this new window opens (see Figure 2) you need to check "Allow Remote Assistance connections to this computer" and then check the middle option under the Remote Desktop section.
After you have taken care of this, click OK and you are ready to connect. Time to go over to your remote Linux machine.
Installing and using rdesktop
Installing rdesktop is simple:
- Open up a terminal window (you'll need one open anyway).
- Enter the command sudo apt-get install rdesktop.
- Enter your sudo command.
- What rdesktop install.
After rdesktop is installed, you're ready. To connect to the remote virtual machine you will enter a command like this:
rdesktop -u USER -p PASSWORD -g RESOLUTION -a COLORDEPTH ADDRESS
- USER is the username of the HOST.
- PASSWORD is the password for the user on the HOST.
- RESOLUTION is the resolution you want to use.
- COLORDEPTH is the amount of colors use (16 or 24).
- ADDRESS is the location of the server housing the virtual machine (including the port).
So the command I use to connect is:
rdesktop -u jlwallen -p password -g 1224x1024 -a 16 192.168.1.100:3389
You will know right away if your connection worked because the virtual machine will open in a new window.
And that's all it takes. You can use this virtual machine as if it were on your local machine.
VirtualBox continues to show itself to be one of the most flexible, useful tools available. By employing a simple tool like rdesktop, you can now connect to a centralized virtual machine server with ease.
And if I need to connect Vista to Remote Virtual? PuTTy? Are default ports–3389–required? Port forwarding? The VM will be using a TAP adapter with an odd IP? I’ve working with VirtualBox, but I’ve never really considered using it as a Remote Machine.
@jasray: Using the latest releases of VirtualBox you shouldn’t have any problem. you are connecting to the IP of the host not the guest so the built in NAT of VirtualBox should take care of it. Now I have never used VB with a TAP. let me know if you have success. And yes, 3389 is the default port.
A grammar Nazi quibble: I suspect when you used the word “cannon”, you meant “canon”.
BTW, one nice thing I discovered about running Windows as a VM on Linux is that if your Linux system is sharing files via Samba, you don’t need the “Shared Folders” option of VirtualBox because the Windows VM is on the same network as your Samba server and will see your file shares nicely, giving you full access to your Linux files.
I think ‘cannon’ should be spelled ‘canon.’ But besides that, this is an excellent post. People tend to either sleep on or be unaware of the value oif these products. Once awareness increases, I think this sector is going to blow up.
Yeah, rdesktop is good. Additionally, one can also connect to a remote virtual machine using tools like logmein, R-HUB remote support servers, Teamviewer etc. These are easy to use and work well.