Gaming industry under DDoS attack. Get DDoS protection now. Start onboarding
  1. Home
  2. Developers
  3. Pre-configure your dev environment with Gcore VM init scripts

Pre-configure your dev environment with Gcore VM init scripts

  • By Gcore
  • May 26, 2025
  • 3 min read
Pre-configure your dev environment with Gcore VM init scripts

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.

Gcore VM creation screen with user data field enabled

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 for the default user of the selected operating system:

#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 devuser with 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.
  • runcmd is for commands that run at the end of boot.
  • Use write_files to 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.

Explore Gcore VM product docs

Related articles

What's the difference between multi-cloud and hybrid cloud?

Multi-cloud and hybrid cloud represent two distinct approaches to distributed computing architecture that build upon the foundation of cloud computing to help organizations improve their IT infrastructure.Multi-cloud environments involve us

What is multi-cloud? Strategy, benefits, and best practices

Multi-cloud is a cloud usage model where an organization utilizes public cloud services from two or more cloud service providers, often combining public, private, and hybrid clouds, as well as different service models, such as Infrastructur

What is cloud migration? Benefits, strategy, and best practices

Cloud migration is the process of transferring digital assets, such as data, applications, and IT resources, from on-premises data centers to cloud platforms, including public, private, hybrid, or multi-cloud environments. Organizations can

What is a private cloud? Benefits, use cases, and implementation

A private cloud is a cloud computing environment dedicated exclusively to a single organization, providing a single-tenant infrastructure that improves security, control, and customization compared to public clouds.Private cloud environment

What is a cloud GPU? Definition, types, and benefits

A cloud GPU is a remotely rented graphics processing unit hosted in a cloud provider's data center, accessible over the internet via APIs or virtual machines. These virtualized resources allow users to access powerful computing capabilities

What is cloud networking: benefits, components, and implementation strategies

Cloud networking is the use and management of network resources, including hardware and software, hosted on public or private cloud infrastructures rather than on-premises equipment. Over 90% of enterprises are expected to adopt cloud netwo

Subscribe to our newsletter

Get the latest industry trends, exclusive insights, and Gcore updates delivered straight to your inbox.