User Data

User Data in Atlas Cloud lets you automatically configure a virtual machine during its first boot. This is useful for tasks like:

  • Adding users and SSH keys
  • Installing software packages
  • Configuring services or network settings
  • Bootstrapping management agents

Example User Data

#cloud-config
users:
  - name: deploy
    groups: sudo
    shell: /bin/bash
    ssh-authorized-keys:
      - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID...
 
package_update: true
package_upgrade: true
 
runcmd:
  - echo "Welcome to Atlas Cloud!" > /etc/motd
  - apt-get install -y curl vim
  • Creates a deploy user with sudo privileges.
  • Adds the specified SSH key for secure login. Use an ed25519 public key, the format recommended in the SSH Key Pairs guide.
  • Updates and upgrades all system packages.
  • Installs curl and vim.
  • Writes a welcome message to /etc/motd.

If your template does not use cloud-init, you can provide a simple script:

#!/bin/bash
useradd -m deploy -s /bin/bash
mkdir -p /home/deploy/.ssh
echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID..." > /home/deploy/.ssh/authorized_keys
chown -R deploy:deploy /home/deploy/.ssh
chmod 700 /home/deploy/.ssh
chmod 600 /home/deploy/.ssh/authorized_keys
echo "Welcome to Atlas Cloud!" > /etc/motd
 

User data is an excellent way to bootstrap your new instance.