DevTools Logo

Cloud-Init Generator

Cloud-Init Generator

Generate and validate secure Cloud-Init user-data YAML for Linux servers.

Runs in your browser
The package manager picks the right sudo group check and warns about apt/yum mix-ups.
Try an example

Cloud-Init options

1 user · 1 file
User 1
File 1

user-data.yaml

23 lines · 411 chars
User "deploy": "ssh-ed25519 AAAA... deploy@example" is not a valid SSH public key (expected ssh-ed25519 AAAA…). Replace placeholders before use.
User "deploy" gets passwordless sudo. Fine for key-only automation users; avoid it for people.
Because users: is set, cloud-init does not create the image's default user (ubuntu, ec2-user…). Add "default" yourself if you still want it.
package_update: true is added so the apt index is refreshed before installing packages.
#cloud-config
hostname: app-server
ssh_pwauth: false
users:
  - name: deploy
    ssh_authorized_keys:
      - ssh-ed25519 AAAA... deploy@example
    sudo: ALL=(ALL) NOPASSWD:ALL
    groups:
      - sudo
package_update: true
packages:
  - curl
  - git
write_files:
  - path: /etc/motd
    content: |
      Managed by cloud-init
    permissions: '0644'
    owner: root:root
runcmd:
  - systemctl enable --now ssh

Examples

Default model round-trips

Input
generateCloudInitYaml(defaultCloudInitModel)
Output
#cloud-config with hostname app-server, users[deploy], packages [curl, git], write_files [/etc/motd], ssh_pwauth: false

The default model emits every section including ssh_pwauth: false, and re-parsing the YAML returns the same structure.

Validation catches three issues

Input
#cloud-config\nssh_pwauth: true\nunknown_setting: yes\nruncmd:\n  - {bad: value}
Output
"Unknown Cloud-Init top-level key: unknown_setting", "ssh_pwauth should be false ...", "runcmd item 1 must be a string or array of strings."

Unknown keys and password auth are warnings while the mapping-shaped runcmd item is an error.

About this tool

Cloud-Init Generator builds #cloud-config documents: buildCloudInitDocument(model) trims and drops blanks across hostname, users (name, ssh_authorized_keys, sudo, groups), packages, write_files (path, content, permissions default 0644, owner default root:root), and runcmd (strings or string arrays, empties removed), while ssh_pwauth: false is always present. generateCloudInitYaml(model) prefixes the js-yaml dump with #cloud-config and is fully deterministic for the same model.

Validation runs on YAML text with validateCloudInitYaml(source) (validateCloudInit returns just the messages): empty input and non-mapping documents are errors, runcmd must be a list whose items are strings or string arrays (anything else, e.g. a {bad: value} mapping, is an runcmd item N must be a string or array of strings error), while unknown top-level keys outside the allowed set (hostname, users, packages, write_files, runcmd, ssh_pwauth, timezone, and friends) and ssh_pwauth values other than false are warnings.

The default model (defaultCloudInitModel) provisions hostname app-server, a deploy user with an ssh key and sudo group, curl and git packages, an /etc/motd file, and a systemctl enable --now ssh command — while an all-empty model collapses to exactly { ssh_pwauth: false }.

How to use this tool

  1. Fill in the server model

    Set hostname, users with SSH keys and sudo/groups, packageManager (apt/yum), packages, writeFiles, and runcmd — blank entries are stripped automatically.

  2. Generate the YAML

    Call generateCloudInitYaml(model): the output starts with #cloud-config and keeps users, write_files, packages, and runcmd in cloud-config shape.

  3. Validate pasted configs

    Run validateCloudInitYaml(source) to catch invalid YAML, unknown top-level keys, ssh_pwauth left true, and non-string runcmd items.

  4. Keep password auth off

    Leave ssh_pwauth false (the default) so password logins stay disabled and only your listed SSH keys grant access.

Use cases

Bootstrapping cloud VMs

Generate first-boot configs that create users, install packages, drop files, and run setup commands on EC2-style instances.

Enforcing key-only SSH

Ship ssh_pwauth: false with ssh_authorized_keys so password authentication stays disabled from first boot.

Linting hand-written cloud-config

Paste existing YAML to surface unknown keys, password-auth regressions, and malformed runcmd entries before launch.

Common mistakes

Mistake:Putting a mapping or number inside runcmd.

Fix:runcmd items must be strings or arrays of strings — a {key: value} entry fails with runcmd item N must be a string or array of strings.

Mistake:Inventing top-level keys.

Fix:Only the known cloud-config keys (hostname, users, packages, write_files, runcmd, ssh_pwauth, timezone, ...) are accepted; anything else warns as unknown.

Mistake:Re-enabling password SSH.

Fix:Any ssh_pwauth value other than false triggers a warning — keep it false and rely on ssh_authorized_keys.

Frequently asked questions

What does this tool do?

It builds a #cloud-config document from your hostname, users, packages, write_files, and runcmd (always including ssh_pwauth: false), generates the YAML text deterministically, and validates pasted cloud-config for unknown keys, password-auth regressions, and malformed runcmd items.

Why is my runcmd item rejected?

runcmd must be a list of strings or string arrays — a mapping like {bad: value} fails with runcmd item N must be a string or array of strings. Rewrite it as a shell string or an argv array such as [systemctl, restart, ssh].

Is my server configuration uploaded or stored?

No. Document building, YAML serialization, and validation all run locally in your browser — hostnames, keys, and file contents never leave your device.

What does an empty model produce?

Exactly { ssh_pwauth: false }: blank hostnames, empty users/packages/files/command lists are all stripped, and the YAML renders just the #cloud-config header plus ssh_pwauth: false.

References & standards