Tuesday, June 04, 2024

How to use GUI in Ubuntu Multipass

Currently, Multipass does not provide a complete graphical interface for use like virtual machine software such as VMware or VirtualBox.

Of course, there are alternative solutions. You can connect to a Multipass instance using RDP, VNC, or X forwarding methods.

Here, I will use the X forwarding method, so when I need to use a GUI, I can launch the graphical interface of the relevant app from the CLI.

Step1. Create an SSH public key on your local machine 

lchiu@lchiu-ThinkPad-X1-Carbon-Gen-11:~$ ssh-keygen 

Generating public/private rsa key pair.

Enter file in which to save the key (/home/lchiu/.ssh/id_rsa): 

Enter passphrase (empty for no passphrase): 

Enter same passphrase again: 

Your identification has been saved in /home/lchiu/.ssh/id_rsa

Your public key has been saved in /home/lchiu/.ssh/id_rsa.pub

Step2. Copy it to the specified Multipass instance

lchiu@lchiu-ThinkPad-X1-Carbon-Gen-11:~$ multipass exec fervent-archerfish -- bash -c "echo `cat ~/.ssh/id_rsa.pub` >> ~/.ssh/authorized_keys"

Note: Where fervent-archerfish is instance's name.

Step3. Obtain the instance's IP info and connect to it from your local machine using SSH

lchiu@lchiu-ThinkPad-X1-Carbon-Gen-11:~$ multipass info fervent-archerfish

Name:           fervent-archerfish

State:          Running

Snapshots:      0

IPv4:           10.183.199.85

Release:        Ubuntu 24.04 LTS

Image hash:     b60205f4cc48 (Ubuntu 24.04 LTS)

CPU(s):         2

Load:           0.00 0.05 0.08

Disk usage:     2.0GiB out of 9.6GiB

Memory usage:   436.0MiB out of 3.8GiB

Mounts:         --

lchiu@lchiu-ThinkPad-X1-Carbon-Gen-11:~$ ssh -X ubuntu@10.183.199.85

Welcome to Ubuntu 24.04 LTS (GNU/Linux 6.8.0-31-generic x86_64)

ubuntu@fervent-archerfish:~$ 

Demonstration -> Use `python3-tk` in the instance






No comments: