Skip to main content

Set a password

By default, password-based SSH authentication is disabled on Gcore Virtual Machines — only SSH key authentication is enabled. Set ssh_pwauth: true to allow password access.
  • password — sets the password for the default OS user (e.g. ubuntu on 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.
After the VM is ready, connect with:

Create a user

Add a users 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 with mkpasswd -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

Set disable_root: false to allow the root user to log in with SSH.

Configure user groups

Add the groups directive to create custom groups at boot.
After the VM is ready, run compgen -g to verify the group appears.

Add an SSH key

Add public SSH keys from other machines using ssh_authorized_keys.
After the VM starts, verify with cat ~/.ssh/authorized_keys.

Add repositories and install packages

Install packages at first boot using the packages 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 the write_files directive.

Configure network interfaces

Add a static IP address by writing a Netplan configuration file. Cloud-init merges it with the auto-generated 50-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).
After the VM reboots, run 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: