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?

Hi Alan,
I do know practically NOTHING about computer tech, I get things done by following written instructions. I have followed one such instruction on YouTube and use multipass to create a vm (or instance?) which is good and running. But, I am stuck there, I have no further instruction as to what I want to do. I want to be able to us the vm to surf the web and use apps not available on my mac m1. from reading your post above, it seems I need a GUI (I don’t know). Please, how do I find instruction for multipass to have Ubuntu interface on my mac to use like I use my Mac? Thanks so very much for your kind support!

@ptcg, Multipass isn’t suited to bringing up a full graphical user interface like GNOME. Apps such as web browsers will lack hardware graphics support, and will likely run slowly, if at all, with the above setup.

The above instructions work on Linux, but I don’t know about MacOS.

For the record: it does work on MacOS (M1 user here).

One thing is not working (or not anymore?): the egmde.remote at the ssh -X step:

  • ssh -X ubuntu@myhostIP egmde did open an X window on my Mac
  • ssh -X ubuntu@myhostIP egmde.remote show egme.remote help text

@clorichel, thanks for the notes. But you appear to have misunderstood egmde.remote

That’s not surprising. egmde.remote is a utility script to help set up a remove VNC server. If you read the help text (“Usage: egmde.remote [ssh-login]”) you’ll see the corresponding command is:

egmde.remote ubuntu@myhostIP

Obviously, to use this script you would first need egmde installed on your host/local system. (Does MacOS support Snaps yet?)

1 Like

You’re totally right! I’m actually not used to egmde, was just fiddling around with the intent of playing with multipass and X11 through ssh -X on my Mac. I guess my comment is not out of interest for Mac users though :slight_smile:

Thanks! Your precisions (here and on other discussions) are always helpful to better understand things :hugs: