Skip to main content

User data

User data or Cloud-init automatically configures the Bare Metal GPU Server after it boots. These scripts are typically used for the initial configuration of the server and are executed at first boot.

When you deploy a server with user data, you can run any commands during provisioning and modify various aspects of the server. Below are some examples of what you can do with user data scripts.

Create a user and install 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

This script:

  • Creates a user named cloud_user.
  • Adds an SSH key to ensure secure remote login.
  • Installs packages such as git (a version control tool) and htop (a system monitor).

How to test: Use the following command format to log in:

ssh -i /.ssh/id_rsa maas_user@10.192.226.195

You can then run htop and try some git commands for further testing.

Set 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

This script:

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

Install Docker

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

This script:

  • Installs Docker on the machine.
  • Enables and starts Docker to ensure it runs when the machine boots.