Skip to content

Cloud-Init

Change the account that cloud-init sets up in a VM made from a Linux cloud image.

📸 Screenshot: Cloud-Init Section

Availability: For Linux VMs created from a cloud image, on Macs with Apple silicon.

Fields

Field Description
Enable Attach the setup disk at start. Off: the VM keeps the account it has.
User The account cloud-init creates. Lowercase letters, digits, - and _; not a system account such as root.
Password A new password, or leave blank to keep the current one. Stored as a SHA-512 hash. Remove leaves SSH key sign-in only and needs an SSH key.
SSH Keys Public keys, one per line, such as the contents of ~/.ssh/id_ed25519.pub. Add Key File… adds the keys in a .pub file. Private keys are refused.
Hostname The guest's hostname. Blank uses the VM name.
User Data Your own cloud-init settings or script, run once after VirtualProg's setup. See User Data.
Set up again at next start Runs the setup again at the next start, without other changes.

The account needs a password, an SSH key, or both.

When Changes Apply

cloud-init starts at every boot, but it only sets the VM up when the VM's instance ID changes. At each start VirtualProg rewrites the setup disk with the ID and your settings. cloud-init compares the ID with the one it saved in the VM: the same ID changes nothing, so a plain restart never sets the VM up again.

The setup runs at the next start after:

Event What happens
The first start The user, password, SSH keys and hostname are set, and the disk grows to its full size.
Saving a new User, Password, SSH Keys, Hostname or User Data The setup runs again with the new values. A password typed again counts as a change, even the same one.
Saving with Set up again at next start The setup runs again without other changes. The option clears after the save.
A copy Clones, linked clones, templates and VMs made from snapshots also get a new machine ID and new SSH host keys.

Restarting, shutting down and changing other settings, such as CPU, memory, disk or display, don't run the setup. Turning Enable off stops attaching the setup disk; turning it on again keeps the instance ID, so nothing runs again.

When the setup runs again in the same VM, files, packages, the machine ID and the SSH host keys stay as they are, so SSH doesn't warn about a changed host key. Only a copy gets new host keys. The setup only adds and updates: a new user is added next to the old one, and a removed SSH key stays in authorized_keys in the VM until you delete it there.

Once a setup is done, the password's hash is left out of the setup disk, because the VM already has it. A setup that runs again puts it back for that run.

User Data

User Data adds your own setup to VirtualProg's: Add… or Edit… opens the editor. Start with #cloud-config for cloud-init settings (YAML), or with #! and an interpreter, such as #!/bin/sh, for a script. Open File… loads a file, and Insert Example starts you off.

Both go on the setup disk as a second part, after VirtualProg's, and run once per setup:

  • Lists are added to VirtualProg's: packages, runcmd, bootcmd, write_files, users and the like. A runcmd of yours runs after VirtualProg's.
  • VirtualProg's own settings stay: hostname, timezone, ssh_pwauth, the account's password and the network come from the VM's settings, even if your user data sets them.
  • A script runs at the end of the first boot, as root.

The editor checks your user data as you type: a missing #cloud-config, tabs in the indentation, a key given twice, a list given as a single value, a quote or bracket left open, and key names cloud-init doesn't know, with a suggestion for a typo. Errors stop the save; warnings don't. It's not a full check: cloud-init checks the rest at boot, and the VM list shows Setup failed with its errors; click it, or Setup Logs → Show… here, for cloud-init's full schema check and logs (see When Setup Fails). Preview shows the whole user-data file on the setup disk, with the password hash hidden.

User data is saved in the VM's settings and stays on the setup disk, so keep secrets such as API tokens out of it, or remove them once the VM is set up. Up to 128 KB.

Command Line

vpvm config cloud-init web1 --password-stdin < password.txt
vpvm config cloud-init web1 --ssh-key ~/.ssh/id_ed25519.pub
vpvm config cloud-init web1 --hostname web1.lan
vpvm config cloud-init web1 --rerun
vpvm config cloud-init web1 --user-data setup.yaml
vpvm config cloud-init web1 --clear-user-data
vpvm config cloud-init web1 --preview
vpvm config info web1 cloud-init

--user-data - reads standard input. vpvm prints the user data's errors and warnings with line numbers before saving.

The web dashboard and mobile apps have a Cloud-Init tab in the VM's configuration, with the user data editor, and config cloud-init in their command lines, with --preview and --clear-user-data.