How to use stand-alone windows in Multipass

Note: Please see instead How to set up a graphical interface.

We explored here and here how to configure a graphical desktop on Multipass. It might be the case that we only want Multipass to launch one application and to see only that window, without having the need for a complete desktop. It turns out that this setup is simpler than the desktop, because we do not need the Multipass instance to deploy a full desktop. Instead, we can use X11 to connect the applications in the instance with the graphical capabilities of the host.

X11 on Windows

The problem is that Windows knows nothing about X. We need to install then an X server. We will use here VcXsrv, which can be found here. Other options would be Xming (however, newest versions are paid but older versions can still be downloaded for free from their SourceForge site) or installing an X server in Cygwin.

The first step would be thus to install VcXsrv and run the X server through the newly created start menu entry “XLaunch”. Some options will be displayed. In the first screen, we should choose “Multiple windows” and set the display number; leaving it in -1 is a safe option. The “Next” button brings us to the “Client startup” window, on which we should choose “Start no client”. “Next” will show us the “Extra settings”, and there we should activate the option “Disable access control”. Pressing “Next” will give us then the option to save the settings, and finally we can start the X server. An icon will show up in the dock: we are done with the X server.

To configure the client (that is, the Multipass instance) we will need first the host IP address, which can be obtained with the console command ipconfig. Then start the instance and set the DISPLAY environment variable to the server display on the host IP:

export DISPLAY=xx.xx.xx.xx:0.0

(replace xx.xx.xx.xx with the IP address obtained above).

To test the setting, we can run in the host some simple program:

sudo apt install x11-apps
xlogo &

A small window containing the X logo must show up. Done!

Linux

Linux and MacOS run X by default, so no extra effort is needed. We have the possibility here to be a bit more secure than we did on Windows, by using authentication in X forwarding. However, we will forward through ssh in order to avoid struggling with xauth stuff. Unfortunately, multipass shell does not let us to pass extra parameters to ssh, so we cannot use the shell through Multipass. We will allow our user in the host to log in to the Multipass instance through ssh, by copying our public key, in file ~/.ssh/id_rsa.pub to the list of authorized keys of the instance, in file ~/.ssh/authorized_keys. We can do this with the following command (replace the example instance name with yours):

multipass exec rocking-squirrel -- bash -c "echo `cat ~/.ssh/id_rsa.pub` >> ~/.ssh/authorized_keys"

Then, check the IP address of the instance, using multipass info rocking-squirrel. Finally, we can log in to the instance using X forwarding doing

ssh -X ubuntu@xx.xx.xx.xx

(replace xx.xx.xx.xx with the IP address obtained above).

We are done, and we can test forwarding using xlogo as we did in the Windows section.

MacOS

The procedure for MacOS should be almost the same as for Linux, but I don’t have a Mac at hand for testing it. Contributions are welcome :slight_smile:

1 Like