Install ubuntu VM on MACOS using multipass And Run Certbot on it
Multipass is the recommended method for creating Ubuntu VMs on Ubuntu. It’s designed for developers who want a fresh Ubuntu environment with a single command, and it works on Linux, Windows and macOS.
1. Install multipass
On Linux and macOS it’s available as a snap:
sudo snap install multipass
2. Find available images
To find available images you can use the following Command
multipass find
command, which will produce a list like this:
Image Aliases Version Description
snapcraft:core18 18.04 20201111 Snapcraft builder for Core 18
snapcraft:core20 20.04 20210921 Snapcraft builder for Core 20
snapcraft:core22 22.04 20220426 Snapcraft builder for Core 22
snapcraft:devel 20221128 Snapcraft builder for the devel series
core core16 20200818 Ubuntu Core 16
3. Launch Instance
You can launch a fresh instance by specifying either the image name from the list (in this example, 22.04) or using an alias, if the image has one.
$ multipass launch 22.04
Launched: cleansing-guanaco
4. Check Out Running Status Of VM
You can check out the currently running instance(s) by using the “multipass list` command:
$ multipass list
Name State IPv4 Image
cleansing-guanaco Running 10.140.26.17 Ubuntu 22.04 LTS
5. Details About The VM
You can use the multipass info
command to find out more details about the VM instance parameters:
$ multipass info cleansing-guanaco
Name: cleansing-guanaco
State: Running
IPv4: 10.140.26.17
Release: Ubuntu 22.04.1 LTS
Image hash: dc5b5a43c267 (Ubuntu 22.04 LTS)
Load: 0.45 0.19 0.07
Disk usage: 1.4G out of 4.7G
Memory usage: 168.3M out of 969.5M
Mounts: --
Connect to a running instance
To enter the VM you created, use the shell
command:
$ multipass shell cleansing-guanaco
Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-53-generic x86_64)
(...)
ubuntu@cleansing-guanaco:~$ sudo su
ubuntu@cleansing-guanaco:~#
Disconnect from the instance
Don’t forget to log out (or Ctrl + D) when you are done, or you may find yourself heading all the way down the Inception levels…
Stop or start an instance
You can stop an instance to save resources using the stop
command:
$ multipass stop cleansing-guanaco
You can start it back up again using the start
command:
$ multipass start cleansing-guanaco
Delete the instance
Once you are finished with the instance, you can delete it as follows:
$ multipass delete cleansing-guanaco
It will now show up as deleted when you use the list
command:
$ multipass list
Name State IPv4 Image
cleansing-guanaco Deleted -- Not Available
And when you want to completely get rid of it (and any other deleted instances), you can use the purge
command:
$ multipass purge
Which we can check again using list
:
$ multipass list
No instances found.
INSTALL CERTBOT IN VM
$ multipass shell cleansing-guanaco
Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-53-generic x86_64)
(...)
ubuntu@cleansing-guanaco:~$ sudo su
ubuntu@cleansing-guanaco:~# snap install --classic certbot
GENERATE SSL
$ multipass shell cleansing-guanaco
Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-53-generic x86_64)
(...)
ubuntu@cleansing-guanaco:~$ sudo su
ubuntu@cleansing-guanaco:~# certbot certonly --manual --preferred-challenges dns -d "*.dns.name.in" -d "dns.name.in"
Enjoy!!!