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-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0...
package_update: true
package_upgrade: true
runcmd:
- echo "Welcome to Atlas Cloud!" > /etc/motd
- apt-get install -y curl vim- Creates a
deployuser withsudoprivileges. - Adds the specified SSH key for secure login.
- Updates and upgrades all system packages.
- Installs
curlandvim. - Writes a welcome message to
/etc/motd.
If your template doesn’t use cloud-init, you can provide a simple script:
#!/bin/bash
useradd -m deploy -s /bin/bash
mkdir -p /home/deploy/.ssh
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0..." > /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.