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):
groups:
  - vscode
runcmd:
  - adduser ubuntu vscode
ssh_authorized_keys:
  - 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!

7 Likes

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