Cloud-init user data
Paste a script or a cloud-config file when you create a server and it runs automatically on first boot.
All our images include cloud-init. Put your user data in the User data box of the create-server form, the user_data field of the API, or --user-data in the CLI. The limit is 64 KB.
A shell script
Start with #! and it runs once as root:
user-data.sh
#!/bin/bash
apt-get update
apt-get install -y nginx
echo "Hello from Kasada Hosting" > /var/www/html/index.htmlA cloud-config file
Start with #cloud-config to use the YAML format:
cloud-config.yaml
#cloud-config
package_update: true
packages:
- nginx
- fail2ban
users:
- name: deploy
groups: sudo
shell: /bin/bash
sudo: "ALL=(ALL) NOPASSWD:ALL"
ssh_authorized_keys:
- ssh-ed25519 AAAAC3Nza... deploy@laptop
runcmd:
- systemctl enable --now nginx
timezone: America/New_YorkInstall Docker
cloud-config.yaml
#cloud-config
runcmd:
- curl -fsSL https://get.docker.com | sh
- usermod -aG docker rootChecking it ran
bash
cloud-init status --wait
sudo cat /var/log/cloud-init-output.logSSH keys you tick in the form are added alongside any users defined in your cloud-config. User data runs on first boot only, and again after a rebuild if you supply it.
Don't put passwords or secret keys in user data you share — anyone in your organization can see it on the server.
