Provisioning a Cloud-Init VM
Proxmox allows you to create both Virtual Machines via QEMU, and Containers via LXC. Out of the box, LXC containers are much easier to provision, you download the template, create the CT and specify the username, password & IP address. Virtual machines take longer to provision, but are much more flexible in usage. One big benefit is live migration without downtime. A container must be restarted when migrating to a different node.
Cloud-Init is a feature that will speed up deployment of Linux-based virtual machines, allowing you to provision a VM as quickly as a CT. This guide will assume that you already have a Debian-based Linux guest installed inside a virtual machine, and that you have OpenSSH server installed.
Logging into the virtual machine
Confirming the IP address
If you are using DHCP, you may need to confirm which IP address has been given to the Virtual machine. To do this, log into the CLI and run the following command:
ip a
This should give an output similar to below. The address we are interested in is the inet address listed below ens18. In this case, the address is 192.168.1.187
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 4a:69:2e:94:d8:56 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.187/24 brd 192.168.1.255 scope global dynamic ens18
valid_lft 86194sec preferred_lft 86194sec
inet6 fe80::4869:2eff:fe94:d856/64 scope link
valid_lft forever preferred_lft forever
SSH'ing into the machine
Then, ssh into your virtual machine:
ssh [email protected]
Enabling root access
During the preparation process, we will need to remove the user created during installation. In order to do this, we will need to log into the virtual machine as the root user.
Setting the root password
Once successfully logged in, you will need to use this command to set a password for the root user. This password will be used for all VMs that use the Cloud-Init template, so it is best to use a secure one!
sudo passwd root
(Optional) Enabling root ssh access
For security reasons, root SSH access is disabled by default. To make things easier, we can temporarily enable root SSH access by modifying the OpenSSH config file:
sudo nano /etc/ssh/sshd_config
Add this line at the top of the file:
PermitRootLogin yes
Then save the file (Ctrl-S) and close Nano (Ctrl-X).
After saving the file, we will need to restart the SSH service for the changes to take affect:
sudo systemctl restart sshd