If you’re a frequent user of VirtualBox, you have come across an instance where you wanted to connect to one of your desktop virtual machines from another computer. No matter how many times you try, it just doesn’t seem to work.

I have the fix for that.

You might be surprised to find out that everything you need to connect to that desktop is actually built into VirtualBox itself. The only third-party software you’ll need is a good RDP client.

I’m going to show you how to connect to a Ubuntu 17.10 guest, on an Elementary OS host, from a macOS client, using Microsoft Remote Desktop. You’ll be surprised at how easy this actually is.

SEE: Remote access policy (Tech Pro Research)

Setup on VirtualBox

Out of the box, remote connections should be enabled. However, it would be wise to check your VM settings and make sure. To do this, open up VirtualBox, select the VM to be configured, click on Display | Remote Display. Make sure Enable Server is enabled and the Server port is set to 3389 (Figure A). If your network won’t allow port 3389, you’ll need to find a port that can be accessed over your internal network.

Figure A

Once you have that configured, your virtual machine must be running (in order for the remote connection to be made). You can do this in one of two ways:

  • Start the VM from the VirtualBox manager GUI
  • Start the VM from the command line

If you only need to access the VM from a remote client, I would recommend starting the VM from the command line. The command to do this is:

VBoxHeadless -s "VM_NAME"

Where VM_NAME is the name of the virtual machine.

When the VM is running headless, it will show up in the VirtualBox GUI, listed as Running. You are ready to connect via RDP.

SEE: The 10 worst things about working from home (free PDF) (TechRepublic)

Connecting from the client

As I mentioned, we’ll be connecting to the VM from macOS, using Microsoft Remote Desktop. Install the application from the App Store and then start it up from the Launchpad. When the application opens, click the + button to create a new connection. In the connection window (Figure B), fill out the following information:

  • Connection name–give the connection a name.
  • PC name–IP address of VirtualBox host (not the guest) in the form 192.168.1.162:3389
  • User name–user name on the guest OS
  • Password–password for the guest OS user

Figure B

That’s the minimum necessary to connect to your VM desktop. Close that window (information is saved automatically) and then, in the main Microsoft Remote Desktop client window (Figure C), double-click on the newly created entry. This will connect to the remote VM and boot the OS.

Figure C

Once the remote guest boots up, you’ll be prompted to log into the desktop and you’re good to work. When you’ve completed working, you can shutdown the guest VM as you would normally.

That’s all there is to connecting to a remote VirtualBox Virtual Machine. Remember, the trick is connecting to the IP address of the host, not the guest. So long as your networking connection is up to the task, using the remote desktop will feel almost as if you’re on the local machine itself.

Subscribe to the Developer Insider Newsletter

From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays

Subscribe to the Developer Insider Newsletter

From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays