Provisioning new cloud instances can be repetitive and time-consuming if you’re doing everything manually: installing packages, configuring environments, copying SSH keys, and more. With cloud-init, you can automate these tasks and launch development-ready instances from the start.
Gcore Edge Cloud VMs support cloud-init out of the box. With a simple YAML script, you can automatically set up a development-ready instance at boot, whether you’re launching a single machine or spinning up a fleet.
In this guide, we’ll walk through how to use cloud-init on Gcore Edge Cloud to:
- Set a password
- Install packages and system updates
- Add users and SSH keys
- Mount disks and write files
- Register services or install tooling like Docker or Node.js
Let’s get started.
What is cloud-init?
cloud-init is a widely used tool for customizing cloud instances during the first boot. It reads user-provided configuration data—usually YAML—and uses it to run commands, install packages, and configure the system. In this article, we will focus on Linux-based virtual machines.
How to use cloud-init on Gcore
For Gcore Cloud VMs, cloud-init scripts are added during instance creation using the User data field in the UI or API.
Step 1: Create a basic script
Start with a simple YAML script. Here’s one that updates packages and installs htop:
#cloud-config package_update: true packages: - htop
Step 2: Launch a new VM with your script
Go to the Gcore Customer Portal, navigate to VMs, and start creating a new instance (or just click here). When you reach the Additional options section, enable the User data option. Then, paste in your YAML cloud-init script.

Once the VM boots, it will automatically run the script. This works the same way for all supported Linux distributions available through Gcore.
3 real-world examples
Let’s look at three examples of how you can use this.
Example 1: Add a password for a specific user
The below script sets the
#cloud-config password: <password>chpasswd: {expire: False} ssh_pwauth: True
Example 2: Dev environment with Docker and Git
The following script does the following:
- Installs Docker and Git
- Adds a new user
devuserwith sudo privileges - Authorizes an SSH key
- Starts Docker at boot
#cloud-config
package_update: true
packages:
- docker.io
- git
users:
- default
- name: devuser
sudo: ALL=(ALL) NOPASSWD:ALL
groups: docker
shell: /bin/bash
ssh-authorized-keys:
- ssh-rsa AAAAB3Nza...your-key-here
runcmd:
- systemctl enable docker
- systemctl start docker
Example 3: Install Node.js and clone a repo
This script installs Node.js and clones a GitHub repo to your Gcore VM at launch:
#cloud-config packages: - curl runcmd: - curl -fsSL https://deb.nodesource.com/setup_18.x | bash - - apt-get install -y nodejs - git clone https://github.com/example-user/dev-project.git
/home/devuser/project
Reusing and versioning your scripts
To avoid reinventing the wheel, keep your cloud-init scripts:
- In version control (e.g., Git)
- Templated for different environments (e.g., dev vs staging)
- Modular so you can reuse base blocks across projects
You can also use tools like Ansible or Terraform with cloud-init blocks to standardize provisioning across your team or multiple Gcore VM environments.
Debugging cloud-init
If your script doesn’t behave as expected, SSH into the instance and check the cloud-init logs:
sudo cat /var/log/cloud-init-output.log
This file shows each command as it ran and any errors that occurred.
Other helpful logs:
/var/log/cloud-init.log /var/lib/cloud/instance/user-data.txt
Pro tip: Echo commands or write log files in your script to help debug tricky setups—especially useful if you’re automating multi-node workflows across Gcore Cloud.
Tips and best practices
- Indentation matters! YAML is picky. Use spaces, not tabs.
- Always start the file with
#cloud-config. runcmdis for commands that run at the end of boot.- Use
write_filesto write configs, env variables, or secrets. - Cloud-init scripts only run on the first boot. To re-run, you’ll need to manually trigger cloud-init or re-create the VM.
Automate it all with Gcore
If you're provisioning manually, you're doing it wrong. Cloud-init lets you treat your VM setup as code: portable, repeatable, and testable. Whether you’re spinning up ephemeral dev boxes or preparing staging environments, Gcore’s support for cloud-init means you can automate it all.
For more on managing virtual machines with Gcore, check out our product documentation.
Related articles
Subscribe to our newsletter
Get the latest industry trends, exclusive insights, and Gcore updates delivered straight to your inbox.






