How to set up a graphical interface

Graphical desktop can be viewed in various ways. In this document, we describe two ways: RDP (Remote Display Protocol) and plain X11 forwarding. Other methods include VNC and running a Mir shell through X11 forwarding (as described here).

Contents:

Using RDP

The images used by Multipass do not come with a graphical desktop installed. For this reason, a desktop environment must be installed (we use ubuntu-desktop but there are as many other options as flavors of Ubuntu exist), along with the RDP server (we will use here xrdp but there are also other options such as freerdp). For this, we must log in to the running Multipass instance first:

$ multipass shell headbanging-squid

and, once inside the instance,

$ sudo apt update
$ sudo apt install ubuntu-desktop xrdp

Then, we need a user with a password in order to log in. One possibility is to set a password to the default ubuntu user.

$ sudo passwd ubuntu

We will be asked to enter and re-enter a password. And we are done on the server side.

We then quit the Ubuntu shell on the instance with the logout command and find out in the host the IP address to connect to:

$ multipass list
Name                    State             IPv4             Image
headbanging-squid       Running           10.49.93.209     Ubuntu 22.04 LTS

Thus, we will use the IP address 10.49.93.209 to connect to the RDP server on the instance.

If the IP address of the instance is not displayed in the output of multipass list, it can be obtained directly from the instance, with the command ip addr.

On Linux

On Linux, there are applications such as Remmina to visualize the desktop (make sure the package remmina-plugin-rdp is installed in your host along with remmina).

To directly launch the client, run the following:

$ remmina -c rdp://10.49.93.209

The system will ask for username (ubuntu) and the password set above, and then the Ubuntu desktop on the instance will be displayed.

Logging in to the RDP server with Remmina

On macOS

To connect on MacOS, we can use the “Microsoft Remote Desktop” application, from the Mac App Store.

On Windows

On Windows, we can connect to the RDP server with the “Remote Desktop Connection” application. There, we enter the virtual machine’s IP address, set the session to XOrg and enter the username and password we created on the previuos step. And we are done… a graphical desktop!

Using X11 forwarding

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 RDP approach, 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.

On Linux

Linux runs X by default, so no extra software in the host is needed. We have the possibility here to be a bit more secure than on Windows, by using authentication in X forwarding. However, we will forward through ssh in order to avoid struggling with xauth stuff. We will allow our user in the host to log in to the Multipass instance through ssh, so that we can pass extra parameters to it. We can achieve that 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 (replace the example instance name with yours):

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

If the file ~/.ssh/id_rsa.pub does not exist, it means that the SSH keys must be created. Use ssh-keygen to create them and retry the copy.

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

# replace `xx.xx.xx.xx` with the IP address obtained above
$ ssh -X ubuntu@xx.xx.xx.xx

And test the setting running on the instance some program:

$ sudo apt -y install x11-apps
$ xlogo &

xlogo on Linux

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

On macOS

The first step in Mac is to make sure a X server is running. The easiest way is to install XQuartz.

Once the X server is running, the procedure for MacOS is the same as for Linux.

Note to Apple Silicon users: some applications requiring OpenGL will not work through X11 forwarding.

On Windows

Windows knows nothing about X, therefore we need to install an X server. Here we will use VcXsrv. 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 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:

# replace `xx.xx.xx.xx` with the IP address obtained above
$ export DISPLAY=xx.xx.xx.xx:0.0

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

1 Like

In macOS follow the Linux instructions, Before you launch any application, export the display variable in the multipass instance and install quartz. Then launch your app.

2 Likes

plus install xquartz in your macOS host, not the linux system.

Couple of additions / comments based on my experience:

Ubuntu Desktop

After installing the Ubuntu Desktop the described way, I neither had a side bar menu and the minimize / maximize buttons were missing on all windows. But it is easy to fix. For the former, create a file named .xsessionrc in the home directory of the user ubuntu and add to following lines to it:

export GNOME_SHELL_SESSION_MODE=ubuntu
export XDG_CURRENT_DESKTOP=ubuntu:GNOME
export XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg

Log out and back in to make the changes applied.

To get back the buttons, open a terminal and execute the following line:

gsettings set org.gnome.desktop.wm.preferences button-layout ":minimize,maximize,close" 

Then the Ubuntu Desktop looks and works as expected.

Kubuntu, Lubuntu

Installing the Kubuntu and Lubuntu desktop works, to too. Just use the meta packages kubuntu-desktop respectively lubuntu-desktop instead.

other Ubuntu flavors

Installing this way the Xubuntu, Ubuntu Mate or one of the other flavor’s desktop leads to an error message von trying zo login with RDP. I believe this is somehow related to having LightDM as the window manager, but I’m not sure about that.

2 Likes

Hello, my computer’s system is Windows 11, and I used Hyper-V and VcXsrv to set up a graphic interface.
I followed the instructions and succeed , but I didn’t want to set the DISPLAY every time I opened my instance so I added “export DISPLAY=xx.xx.xx.xx:0.0” to ~/.bashrc , it worked well :grinning:.
However, when I restarted my computer, I got the error “can’t open the display”, then I found that my IP had changed, so I had to change ~/.bashrc again.
So is there a way to set the IP permanently ? :thinking:

So is there a way to set the IP permanently?

You would have to configure your router/DHCP server to assign a static IP to that device (the one with that MAC address).

Thanks! I will try it later. :smile:

Hi,

I have follow the instructions for using x11 forwarding on Windows. I use wsl2 the app is ubuntu 22.04 and I am running the first tutorial of fenicsx. There, to visualize the results you need to use pyvista. When I run the part related to the plotting I get the follwing message on the prompt:

trame

But I do not see any plot. If I kill the process (i.e. cltr+C) I will get messages such as:
“connection to :99 broken (explicit kill or server shutdown)”
"falat IO error 4 (Interrupted system call) on X server “:99"”

I have the feeling that the error somehow is related to the fact that the server should be 0.0 and not 99, but after running export DISPLAY=(IPv4-Adresse):0.0, I get the same results.

Do you know what is the problem? What do you recommend me to do?

Thanks

(Sorry if I do not explain myself correctly)

Hi @danijara!

I believe you’ve posted under the wrong project. I think you say you are using WSL2 w/ Ubuntu 22.04, but this project is Multipass which is not WSL2. If I am wrong and you are indeed using Multipass, please let us know and we’ll see if we can help although this how-to is a “best effort” in using graphical apps.

1 Like

You are right, sorry. Should I delete the post?