# cloud-init

> A tool that sets up a new server when it first starts. It reads a file you give it.

**Field:** Infrastructure  
**Category:** Renting a Server (VPS)  
**Also known as:** Cloud-Init, cloud-config, #cloud-config, Server User Data

## Think of it like

Think of it like a note you leave for a new helper. They read it on day one and do every job on the list.

## Definition

cloud-init is the tool that sets up a new server the first time it starts. You give it a short file when you make the server. The file can add users, put in SSH keys, install packages and run commands. It is written in YAML and starts with the line #cloud-config. Most VPS and cloud providers support it.

## Example

Lucy pastes a cloud-init file into the box when she makes a server. It boots with her key, her user and nginx already in place.

## Example code

```yaml
#cloud-config
package_update: true
packages:
  - nginx
  - fail2ban
```

On first boot, update the package list, then install nginx and fail2ban.

## Why it matters

Every new server comes up the same way. There is no clicking and no step left out.

## Common mistake

Leaving out the #cloud-config line at the top. Without it, the file is not read as config at all.

## Three principles

- **First boot.** It runs as the server starts.
- **One file.** YAML, starting with #cloud-config.
- **Same every time.** No steps forgotten.

## Related terms

- [Virtual Private Server (VPS)](https://learn.benibix.com/term/infrastructure/virtual-private-server)
- [Advanced Package Tool (APT)](https://learn.benibix.com/term/infrastructure/apt)
- [SSH Key Pair](https://learn.benibix.com/term/infrastructure/ssh-key-pair)
- [YAML Ain't Markup Language (YAML)](https://learn.benibix.com/term/development/yaml)

## Taught in

- [Creating a VPS with cloud-init](https://learn.benibix.com/learn/infrastructure-vps/creating-a-vps-with-cloud-init): VPS, 4/7

![A timeline for one server. At creation, a cloud-init file installs nginx on first boot. Later, a web console in the browser shows the server's screen when SSH is down. When the server will not boot, rescue mode starts a small system from the network so the disk can be mounted and fixed.](https://learn.benibix.com/diagrams/inf3-provisioning.svg)

---

Source: https://learn.benibix.com/term/infrastructure/cloud-init
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
