May 16, 2022

Customizing VM at Launch with cloud-init

Multipass is great. With cloud-init, it is getting better. 

With cloud-init we can customize our virtual machine at launch when we create them with Multipass.

First, create a cloud-init.yaml file with the content below:

ssh_authorized_keys:
  - ssh-rsa AAAAB3NzaC1yc2EAAAAD........./FAC8DD2xi2pZZc3Dnv/6iE= xx@pf

Next, create the VM with the command below, and list the IP address:

$ multipass launch --name jj --cloud-init cloud-init.yaml

$ multipass list

Last, just ssh into the VM

$ ssh -l ubuntu 10.163.216.36

ssh into VM