A simple GUI Shell for a Multipass VM

A simple GUI Shell for a Multipass VM

Multipass

Multipass is an easy way to run a VM on a variety of platforms. But the VM doesn’t have graphics support and this can be limiting.

Mir

Mir is a set of libraries that facilitate building GUI shells and provides a number of “platforms” that these run on, one of these “platforms” is X11.

The Mir X11 platform is important here because we can use ssh “X forwarding” to run a GUI shell on a

Egmde

Egmde is a GUI shell built with Mir and available as a “snap”.

Putting it together

What follows assumes that you’ve (for example) set up ssh on your host system. (So that, for example, cat ~/.ssh/id_rsa.pub works. I think that a reasonable assumption for anyone reading this far but I’ll make it explict.

We can put all the above pieces together as follows:

#!/bin/sh
multipass launch -n egmde-multipass --cloud-init - <<EOF
ssh_authorized_keys:
    - $(cat ~/.ssh/id_rsa.pub)
packages:
    - xwayland
    - fonts-freefont-ttf
    - gnome-terminal
    - libglib2.0-bin
runcmd:
    - sudo snap install --classic --edge egmde
EOF

This sets up a VM called egmde-multipass with egmde, a couple of packages it needs and enables ssh access.

We can then use this VM as follows:

multipass start egmde-multipass
ssh -X ubuntu@$(multipass info egmde-multipass --format csv | awk -F, '/^egmde-multipass/ { print $3 }') egmde.remote

This will open a “remote” egmde shell as a “Mir-on-X” window on your desktop.

In your VM you can install and run X or Wayland based applications and these will appear by the magic of X-forwarding in the “Mir-on-X” window on your desktop.

4 Likes

I’ve been using variants of this approach for a few other things, and I’ve been told a lot of people are using Multipass with ssh -X forwarding. So here’s a multipass-ssh-X script I’ve been using that might help others:

#!/bin/bash
set -euo pipefail
multipass start $1
host_ip=$(multipass info $1 --format csv | awk -F, '/^'$1'/ { print $3 }')
ssh -X "ubuntu@${host_ip}" "${@:2}"

With this on your $PATH (e.g. ~/bin) you can invoke egmde in the above VM as follows:

multipass-ssh-X egmde-multipass egmde

As you can see, this just sets up an ssh command so, for example, you can get a shell with X-forwarding enabled with:

multipass-ssh-X egmde-multipass
1 Like

A post was split to a new topic: Why does multipass.gui invoke xterm?