User data
User data
Updated on 16 May 2025

User data or Cloud-init automatically configures Bare Metal GPU servers after bootup. These scripts are generally used for the initial configuration of a server and run on the first boot. Deploying a server with user data allows you to run arbitrary commands and change several aspects of the server during provisioning.


Here are a few examples of what you can do with user data scripts:

Creating a user and installing basic packages

#cloud-config
users:
  - name: cloud_user
    ssh_authorized_keys:
      - ssh-rsa AAAAB3Nz... user@domain
    sudo: "ALL=(ALL) NOPASSWD:ALL"
    groups: sudo
    shell: /bin/bash
packages:
  - git
  - htop

What this script does:

  • Creates a user named cloud_user.
  • Adds an SSH key to allow secure remote login.
  • Installs packages like git (a version control tool) and htop (a system monitor). How you can test it:
    To login, you’ll want to use a command of this form:
ssh -i /.ssh/id_rsa maas_user@10.192.226.195

You can then test it further by running htop and trying out some git commands.

Setting up SSH keys for multiple users

#cloud-config
users:
  - default
  - name: user1
    ssh_authorized_keys:
      - ssh-rsa AAAAB3Nz... user1@domain
  - name: user2
    ssh_authorized_keys:
      - ssh-rsa AAAAB3Nz... user2@domain

What this script does:

  • Sets up a default user.
  • Creates user1 and user2 with their own SSH keys for secure login.

Installing Docker

#cloud-config
packages:
  - docker.io
runcmd:
  - systemctl enable docker
  - systemctl start docker

What this script does:

  • Installs Docker on the machine.
  • Enables and starts Docker to make sure it’s running whenever the machine boots up.