Playing with UTM virtual machines on MacOS Sonoma

It’s been a while since I used Linux VMs on a Mac, I last did with VirtualBox a few years ago. In 2023 UTM is the way to go. Download the app (via the App Store or manually).

You can then create a new VM using an existing image. The simplest way is through the UTM Gallery. You might want to choose an ARM64 image for better performance.

Go with “Open in UTM”. It will download everything (it might take some time). You can then start it and use it regularly.

SSH-ing into the VM

When the VM is not running, go to the settings and set Network Mode to “Emulated VLAN”.

Add a new Port Forwarding entry (that section won’t be visible if you are in a different Network Mode), mapping VM’s port 22 to the guest’s 22022 (or any other port you like).

The UI is partially broken, but the result should be

You can then start the VM and you should be able to ssh into it with

ssh ubuntu@localhost -p 22022

Sharing a directory

That’s quite simple, too. Just select one in the Shared Directory option and it will be mounted in /media/share.