Free tools / cloud-init generator

Cloud-init user-data generator

Create a #cloud-config file that sets up a new Ubuntu or Debian server on first boot: a sudo user with your SSH key, root and password login turned off, updates, a firewall, fail2ban and automatic security updates. Copy it or download it as a .yaml file.

Everything runs in your browser. Nothing you type is sent to a server or stored.

User and SSH

Packages and system

Security services

  • No SSH key added. With password login off you will not be able to log in. Paste your public key.
user-data.yaml
#cloud-config
# Generated at nocthost.com/tools/cloud-init-generator

users:
  - name: "deploy"
    groups: [sudo]
    shell: /bin/bash
    sudo: "ALL=(ALL) NOPASSWD:ALL"
    lock_passwd: true

# Block root over SSH and turn off SSH password login
disable_root: true
ssh_pwauth: false

package_update: true
package_upgrade: true
packages:
  - "curl"
  - "git"
  - "htop"
  - "ufw"
  - "fail2ban"
  - "python3-systemd"
  - "unattended-upgrades"

timezone: "UTC"

write_files:
  - path: /etc/fail2ban/jail.local
    defer: true
    content: |
      [sshd]
      enabled = true
      port = 22
      backend = systemd
      maxretry = 5
      findtime = 10m
      bantime = 1h
  - path: /etc/apt/apt.conf.d/20auto-upgrades
    defer: true
    content: |
      APT::Periodic::Update-Package-Lists "1";
      APT::Periodic::Unattended-Upgrade "1";

runcmd:
  - "ufw default deny incoming"
  - "ufw default allow outgoing"
  - "ufw limit 22/tcp"
  - "ufw allow 80/tcp"
  - "ufw allow 443/tcp"
  - "ufw --force enable"
  - "systemctl enable fail2ban"
  - "systemctl restart fail2ban"
  - "systemctl enable --now unattended-upgrades"

How to use

  1. Paste your SSH public key, the line that starts with ssh-ed25519 or ssh-rsa. Without it you cannot log in once password login is off.
  2. Choose the packages, firewall ports and extras you want on the server.
  3. Copy the output or download it as user-data.yaml.
  4. Paste it into the user data or cloud-init field when you create a server, or pass the file to your provider's CLI. Optionally validate it first with cloud-init schema -c user-data.yaml.
  5. After the first boot, log in as the new user and check /var/log/cloud-init-output.log if something did not run.

Frequently asked questions

Where do I put this file?

Most cloud providers have a user data or cloud-init field in the create server form, and their CLIs and APIs accept the same content. cloud-init reads it once, on the first boot of a new server.

Does it work on an existing server?

Not as is. cloud-init runs these modules only on the first boot of an instance. On a server that is already running, run the equivalent commands by hand, or use the sshd and ufw generators on this site.

Which distributions does it support?

The output targets Ubuntu 22.04 and newer and Debian 12 and newer, which ship cloud-init in their cloud images. The sudo group, the package names and the unattended-upgrades setup are Debian family specifics.

How do I check that it ran?

Run cloud-init status --long after logging in. Output from package installs and runcmd is in /var/log/cloud-init-output.log, and errors are in /var/log/cloud-init.log.

Further reading

More free tools

Need a server to try it on? Deploy a Debian VPS