Writing for XDA involves working across different platforms, operating systems, and programs. I frequently try out different apps and tools, which is exactly why I even set up a home lab. Most of the software I use regularly is self-hosted, so I can access all the required services remotely — regardless of which machine I'm using. This is useful since I travel quite frequently and hence, don't have access to all my computers at all times. I primarily use a MacBook when traveling, since the other computer I have is a Windows desktop that also has Ubuntu installed for when I want to use Linux. However, this started to become an issue when traveling, since I also needed access to those operating systems at times.
So, I tried using a Virtual Machine, or VM, directly on my Mac. While that worked well for the most part, the primary issue was performance. My MacBook has the now-dated M1 Pro chip with 16GB of RAM and 512GB of storage. I had to allocate a good chunk of resources to the VM, which meant that the performance of my laptop and the OS in the VM were both taking a hit. That's when I had to look for alternatives. After a bit of research, I figured that I could self-host a remote desktop inside a VM, so I can remotely access it while it runs on a more powerful system at home. Initially, I assumed the process would be complex, and the performance would take a hit. But after using it for a few days, I can confidently say that Ubuntu on my Mac runs as smoothly as a native installation. I'll show you how you can achieve the same result.
Setting up a VM using VirtualBox
It's super simple
Once you pick the machine on which you want to host the VM, download VirtualBox for the corresponding OS. Optionally, it's also recommended to install the Extension Pack for better performance. After you have both of them installed, it's time to download the required ISO image of the OS you wish to install on the VM. I picked Ubuntu because I wanted a Linux distro at my disposal when traveling. You can also choose to install Windows. Download and save the ISO file in an easily accessible directory on your computer.
With all the required files and software, it's time to create a VM. Click the New button in VirtualBox. Select the downloaded ISO, give your VM a relevant name, set the type of OS based on the chosen ISO file, and allocate the required resources. It's recommended to allot at least 4GB of RAM and 20-30GB of storage. Once installed, it's time to start the VM. Go through the installation process and set up a working instance of Ubuntu on your computer. With all of this sorted, it's time to make the VM accessible remotely.
Installing XRDP and XFCE
Configuring remote access
XRDP is an open-source tool that enables remote desktop access to the VM using the Remote Desktop Protocol. Here's how to install it and host your VM on your local network.
-
Update Ubuntu using the following command in the Terminal -
sudo apt update && sudo apt upgrade -y
-
Use the following command to install XRDP and XFCE, a lightweight desktop environment.
sudo apt install xrdp xfce4 xfce4-goodies -y
-
Then, enter both of these commands one after the other:
echo xfce4-session > ~/.xsession
sudo systemctl enable xrdp
sudo systemctl start xrdp
With that out of the way, it's time to configure VirtualBox's networking parameters to access the VM remotely. Shut down the VM. In VirtualBox, select your VM and go to Settings > Network. Set Adapter 1 to NAT. Then, click on Port Forwarding. Next to Rule 1, set the Protocol to TCP, Host Port to 3389, and Guest Port to 3389. Leave the other fields blank and click on OK to save.
Now, download an app like Microsoft Remote Desktop (it's now called Windows App on macOS). Select Add PC and enter your host machine's IP address and port to access it. Note that you need to be connected to the same network to do this. Now, you may wonder how to access the VM when you're traveling and not connected to the same network. There are a couple of options.
The best option, by far, is to install something like Tailscale or host a WireGuard VPN for remote access, port forwarding the latter in your router so that you can gain secure access to your home network. Both of these are significantly safer and more secure options than simply port forwarding the remote access port to the entire machine. You can also configure a Cloudflare Tunnel, or use any other alternative that requires an additional layer of authentication that doesn't go straight to your VM.
However, if you're really set on exposing your VM to the internet, which you really shouldn't do given the prevalence of safe and secure options, you can do so. Go to your router's settings page and find the Port Forwarding or Virtual Server setting. Add a rule with the External and Internal Ports as 3389, Protocol as TCP, and the Internal IP as the host's IP address. Then, find the public IP address of the host machine and enter it with the port number in Microsoft Remote Desktop to access the VM remotely.
You can run a similar deployment in software like Proxmox, and even use tools like Parsec or RustDesk for remote desktop access. There are a lot of ways to make this work, but you should always ensure that security is at the forefront of your setup.
It exceeded my expectations
There's always some sort of hesitation surrounding VMs, primarily because most users are worried that they'll end up eating resources, causing performance issues. Moreover, several VMs provide a laggy experience when allotted minimal resources, so they're not usable for serious work. Hosting a remote desktop inside a VM addresses this issue perfectly, since the VM is technically running on a separate machine. You are only accessing it remotely over the network, so you only have to take care of the required bandwidth without worrying about your machine slowing down when working.
