Set a password
By default, password-based SSH authentication is disabled on Gcore Virtual Machines — only SSH key authentication is enabled. Setssh_pwauth: true to allow password access.
password— sets the password for the default OS user (e.g.ubuntuon Ubuntu images).chpasswd: { expire: false }— keeps the password active without requiring a change on first login.ssh_pwauth: true— enables password-based SSH authentication.power_state— reboots the VM after cloud-init finishes so the changes take effect.
Create a user
Add ausers block to create a new OS user at boot. The example below creates a guest user with sudo access.
sudo: ALL=(ALL) NOPASSWD:ALL— grants the user passwordless sudo rights.passwd— SHA-512 encrypted password. Generate it withmkpasswd -m sha512crypt guest.groups— comma-separated list of groups. The groups must already exist on the system.lock_passwd: false— allows password-based login.shell: /bin/bash— sets the default shell.
Run
groups after connecting to verify group membership.Enable root user
Setdisable_root: false to allow the root user to log in with SSH.
Configure user groups
Add thegroups directive to create custom groups at boot.
compgen -g to verify the group appears.
Add an SSH key
Add public SSH keys from other machines usingssh_authorized_keys.
cat ~/.ssh/authorized_keys.
Add repositories and install packages
Install packages at first boot using thepackages directive. Packages from external repositories require an apt.sources entry.
The example below uses
apt and applies to Debian-based distributions (Ubuntu, Debian). For RPM-based distributions (CentOS, Rocky Linux, Fedora), use the yum_repos directive and replace packages entries with the corresponding package names.Write files
Create files on the VM at boot using thewrite_files directive.
Configure network interfaces
Add a static IP address by writing a Netplan configuration file. Cloud-init merges it with the auto-generated50-cloud-init.yaml during boot.
Netplan applies to Ubuntu. For other distributions, write the appropriate network configuration file for the system’s network manager (for example, NetworkManager connection files on Rocky Linux or CentOS).
ip a to verify the static addresses appear on the enp3s0 interface.
Check cloud-init logs
Two log files are available on the VM for diagnosing cloud-init issues./var/log/cloud-init.log — full process log with debug output:
/var/log/cloud-init-output.log — stdout/stderr from scripts cloud-init ran: