Using xfreerdp with Vagrant

June 15, 2021 – Samuli Seppänen

Vagrant has built-in support for connecting to Windows VMs using the vagrant rdp command. It does basically does the same as vagrant ssh for Linux VMs. There are a few shortcomings, though: vagrant rdp fails to automatically accept the host key of the VM it is connecting to, at least when using it from Linux with xfreerdp. So, you first need to connect to the VM directly once with raw xfreerdp, then vagrant rdp will start working. Then, when you wipe out the VM, you need to repeat the process again. If you have a high resolution screen you will also notice that vagrant rdp will give you a tiny Windows desktop where you need a magnifying glass to read the text.

Given all this the best solution on a Linux host system is to use xfreerdp directly. First you need to figure out the port your Windows VM is listening on. Unless you have tons of Windows VMs running using netstat is probably easiest:

$ netstat -plnt|grep 3389
tcp    0    0*    LISTEN    -

Then connect to the VM directly using xfreerdp command-line, adjusting the screen resolution as needed:

$ xfreerdp /v: /u:vagrant /p:vagrant /smart-sizing:2000x1500

The /smart-sizing switch scales the resolution (fonts, icons) of Windows to match the define screen size thus keeping them legible. What it does not do is ensure that the aspect ratio is correct - for that you need to do a bit of experimentation or actually calculate reasonable numbers that match your screen's aspect ratio.

Want to talk to an expert?

If you want to reach us, just send us a message or book a free call!