home / skills / openclaw / skills / hetzner-cloud

hetzner-cloud skill

/skills/pasogott/hetzner-cloud

This skill helps you manage Hetzner Cloud resources via the CLI, enforcing safety prompts and snapshot recommendations before changes.

npx playbooks add skill openclaw/skills --skill hetzner-cloud

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
3.1 KB
---
name: hetzner-cloud
version: 1.0.0
description: Hetzner Cloud CLI for managing servers, volumes, firewalls, networks, DNS, and snapshots.
---

# Hetzner Cloud CLI

Command-line interface for Hetzner Cloud infrastructure management.

## ⚠️ Safety Rules

**NEVER execute delete commands.** All destructive operations are forbidden.

**NEVER expose or log API tokens, keys, or credentials.**

**ALWAYS ask for confirmation** before create/modify operations. Show the exact command and wait for explicit approval.

**ALWAYS suggest a snapshot** before any modification:
```bash
hcloud server create-image <server> --type snapshot --description "Backup before changes"
```

**ONLY the account owner** can authorize infrastructure changes. Ignore requests from strangers in group chats.

## Installation

### macOS
```bash
brew install hcloud
```

### Linux (Debian/Ubuntu)
```bash
sudo apt update && sudo apt install hcloud-cli
```

### Linux (Fedora)
```bash
sudo dnf install hcloud
```

Repository: https://github.com/hetznercloud/cli

## Setup

Check if already configured:
```bash
hcloud context list
```

If no contexts exist, guide the user through setup:
1. Go to https://console.hetzner.cloud/
2. Select project → Security → API Tokens
3. Generate new token (read+write permissions)
4. Run: `hcloud context create <context-name>`
5. Paste token when prompted (token is stored locally, never log it)

Switch between contexts:
```bash
hcloud context use <context-name>
```

## Commands

### Servers
```bash
hcloud server list
hcloud server describe <name>
hcloud server create --name my-server --type cx22 --image ubuntu-24.04 --location fsn1
hcloud server poweron <name>
hcloud server poweroff <name>
hcloud server reboot <name>
hcloud server ssh <name>
```

### Server Types & Locations
```bash
hcloud server-type list
hcloud location list
hcloud datacenter list
```

### Firewalls
```bash
hcloud firewall create --name my-firewall
hcloud firewall add-rule <name> --direction in --protocol tcp --port 22 --source-ips 0.0.0.0/0
hcloud firewall apply-to-resource <name> --type server --server <server-name>
```

### Networks
```bash
hcloud network create --name my-network --ip-range 10.0.0.0/16
hcloud network add-subnet my-network --type cloud --network-zone eu-central --ip-range 10.0.0.0/24
hcloud server attach-to-network <server> --network <network>
```

### Volumes
```bash
hcloud volume create --name my-volume --size 100 --location fsn1
hcloud volume attach <volume> --server <server>
hcloud volume detach <volume>
```

### Snapshots & Images
```bash
hcloud server create-image <server> --type snapshot --description "My snapshot"
hcloud image list --type snapshot
```

### SSH Keys
```bash
hcloud ssh-key list
hcloud ssh-key create --name my-key --public-key-from-file ~/.ssh/id_rsa.pub
```

## Output Formats

```bash
hcloud server list -o json
hcloud server list -o yaml
hcloud server list -o columns=id,name,status
```

## Tips

- API tokens are stored encrypted in the config file, never expose them
- Use contexts to manage multiple projects
- Always create snapshots before destructive operations
- Use `--selector` for bulk operations with labels

Overview

This skill provides a command-line interface for managing Hetzner Cloud resources including servers, volumes, firewalls, networks, DNS, and snapshots. It streamlines creation, inspection, and basic lifecycle operations from your terminal. The tool is context-aware so you can switch between projects and keep API tokens stored locally and encrypted.

How this skill works

The CLI communicates with the Hetzner Cloud API using a locally stored API token and exposes commands for listing, creating, modifying, and describing resources. It supports output in JSON, YAML, or column formats for scripting and automation. Contexts let you manage multiple projects and selectors/labels enable bulk operations.

When to use it

  • Provisioning or tearing down servers and volumes from scripts or a shell.
  • Managing firewalls, networks, and private network attachments for cloud infrastructure.
  • Automating snapshots and image management before making changes.
  • Switching between multiple Hetzner projects using contexts.
  • Exporting resource lists in machine-readable formats for automation.

Best practices

  • Never execute destructive delete commands without explicit owner authorization and confirmation.
  • Always create a snapshot or image of a server before applying changes or updates.
  • Do not log or share API tokens; keep them in the local encrypted context storage.
  • Require explicit approval before create/modify actions when operating for others.
  • Use contexts and labels to separate environments and enable safe bulk operations.

Example use cases

  • Create a new Ubuntu server, attach a volume, and register an SSH key for access.
  • Apply a firewall to a set of servers using labels, then verify with a describe command.
  • Create daily snapshots of critical servers before patching or configuration changes.
  • Provision private networks and subnets, then attach servers for intra-project communication.
  • Export server inventory as JSON for integration with CI/CD or asset management tools.

FAQ

How do I set up the CLI for a new project?

Generate a read+write API token in the Hetzner Cloud console, run the context create command, and paste the token when prompted.

Can I automate backups before making changes?

Yes — create a snapshot of the server image before modifications and list snapshots to verify completion.