Using Multipass with vscode

Hi everyone, I thought I’d share a blog post I wrote recently about using Multipass as a vscode linux remote development environment. Shout out to @damdam for the idea to use cloud-init to streamline the process!

For those who just want the steps without the whole blog post:

  1. Install vscode and the “Remote - SSH” extension from Microsoft
  2. Create a new RSA key ssh-keygen -t rsa
  3. Create a cloud-init YAML file named vscode.yaml containing this (replacing with your public key that you generated):
  - vscode
  - adduser ubuntu vscode
  - ssh-rsa <public key>
  1. multipass launch --cloud-init vscode.yaml to create the environment with the key
  2. Add the host to vscode by following the prompts and entering the IP address of the instance

Let me know if there are ways you would improve this, or if you have any other thoughts or feedback.

Happy coding!


Next step, implement a VsCode extension to configure and launch Multipass instance with VsCode UI like DevContainers :wink:

1 Like

It is easier to adjust SSH client configuration to use private key provided by Multipass, for example, on Windows

IdentityFile C:\ProgramData\Multipass\data\ssh-keys\id_rsa

This way one can avoid additional steps like SSH key generation writing could-init YML, etc.

i followed your procedure here is what i got

just after creating the foo instance , then i followed your procedure which set am i missing.

Hi @edbertkwesi, that message means that Multipass could not reach the image servers to download the image. You may have been unlucky and tried to launch when they were down. Have you tried again since then? And did you have a working internet connection?

Brilliant ! Thank you so much for your contribution. As I use VS Code a lot so, combining it with multipass is double-win !

I copied your instructions to my repository where I upload some docker compose templates, for anyone interested :

1 Like

I created a DevPod provider for Multipass that will do what you’re looking for. Check it out!

Hi, is there a way to explicitly indicate a net mask or ip4 range for the vscode.yaml to generate containers available in the local network? …or is there an easy way to bridge to host?

I’m trying to remote connect from a machine in the same network but I’m using 192.168.x.x for my machines, whereas multipass is generating 10.x.x.x ip4 for the container.

Thank you!

Hi @juanqg, in backends that support it, you can use --network option in launch to include other network interfaces in new instances. The simplest use is to automatically bridge to a host network interface that supports bridging, as a way to get an IP in your LAN inside the instance. But you can also configure it manually, for example, to get a static IP.

We’re also working on supporting adding networks to existing instances, which we’ll release in a not too distant future (probably in a couple of releases).

I made a vscode extension that manages Multipass within vscode, as well as the option to setup an instance in the same way as this tutorial does.

Multipass Manager - Visual Studio Marketplace