Hetzner Cloud CLI
by @jpj069
Manage Hetzner Cloud infrastructure using the hcloud CLI. Use when working with Hetzner servers, firewalls, networks, volumes, load balancers, or any Hetzner...
clawhub install hcloudπ About This Skill
name: hcloud description: Manage Hetzner Cloud infrastructure using the hcloud CLI. Use when working with Hetzner servers, firewalls, networks, volumes, load balancers, or any Hetzner Cloud resources. Supports server management (create/delete/start/stop), firewall configuration, SSH key management, volume operations, and infrastructure monitoring.
Hetzner Cloud CLI (hcloud)
Manage Hetzner Cloud infrastructure with the official CLI tool.
Prerequisites
Installation (if not already installed):
# Detect architecture
ARCH=$(uname -m)
if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
URL="https://github.com/hetznercloud/cli/releases/latest/download/hcloud-linux-arm64.tar.gz"
else
URL="https://github.com/hetznercloud/cli/releases/latest/download/hcloud-linux-amd64.tar.gz"
fiInstall
cd /tmp
wget -q "$URL"
tar xzf hcloud-linux-*.tar.gz
sudo mv hcloud /usr/local/bin/
chmod +x /usr/local/bin/hcloud
Configuration (first time):
mkdir -p ~/.config/hcloud
cat > ~/.config/hcloud/cli.toml <[[contexts]]
name = "default"
token = "YOUR_HETZNER_API_TOKEN"
EOF
chmod 600 ~/.config/hcloud/cli.toml
Verify:
hcloud version
hcloud server list
Common Commands
Servers
# List servers
hcloud server listGet server details
hcloud server describe Create server
hcloud server create \
--name my-server \
--type cx11 \
--image ubuntu-24.04 \
--ssh-key \
--location nbg1Start/stop/reboot
hcloud server start
hcloud server stop
hcloud server reboot Delete server
hcloud server delete SSH into server
hcloud server ssh Run command on server
hcloud server ssh -- 'uname -a'
Firewalls
# List firewalls
hcloud firewall listGet firewall details
hcloud firewall describe Create firewall
hcloud firewall create \
--name my-firewall \
--rules-file rules.jsonAdd rule to firewall
hcloud firewall add-rule \
--direction in \
--port 22 \
--protocol tcp \
--source-ips 0.0.0.0/0 \
--source-ips ::/0 \
--description "SSH"Apply firewall to server
hcloud firewall apply-to-resource \
--type server \
--server Remove firewall from server
hcloud firewall remove-from-resource \
--type server \
--server Delete firewall
hcloud firewall delete
SSH Keys
# List SSH keys
hcloud ssh-key listAdd SSH key
hcloud ssh-key create \
--name my-key \
--public-key-from-file ~/.ssh/id_ed25519.pubDelete SSH key
hcloud ssh-key delete
Server Types & Images
# List available server types
hcloud server-type listList available images
hcloud image list
hcloud image list --type system # Only system imagesList locations
hcloud location list
Volumes
# List volumes
hcloud volume listCreate volume
hcloud volume create \
--name my-volume \
--size 10 \
--location nbg1Attach volume to server
hcloud volume attach Detach volume
hcloud volume detach Delete volume
hcloud volume delete
Networks
# List networks
hcloud network listCreate network
hcloud network create \
--name my-network \
--ip-range 10.0.0.0/16Add subnet
hcloud network add-subnet \
--type cloud \
--network-zone eu-central \
--ip-range 10.0.1.0/24Attach server to network
hcloud server attach-to-network \
--network
Load Balancers
# List load balancers
hcloud load-balancer listCreate load balancer
hcloud load-balancer create \
--name my-lb \
--type lb11 \
--location nbg1Add target (server)
hcloud load-balancer add-target \
--server Add service
hcloud load-balancer add-service \
--protocol http \
--listen-port 80 \
--destination-port 80
Firewall Rules Format
For complex firewall rules, use JSON:
[
{
"direction": "in",
"port": "22",
"protocol": "tcp",
"source_ips": ["0.0.0.0/0", "::/0"],
"description": "SSH"
},
{
"direction": "in",
"port": "80",
"protocol": "tcp",
"source_ips": ["0.0.0.0/0", "::/0"],
"description": "HTTP"
},
{
"direction": "in",
"port": "443",
"protocol": "tcp",
"source_ips": ["0.0.0.0/0", "::/0"],
"description": "HTTPS"
},
{
"direction": "in",
"protocol": "icmp",
"source_ips": ["0.0.0.0/0", "::/0"],
"description": "ICMP (ping)"
}
]
Common Server Types
| Type | vCPU | RAM | Disk | Price/mo (approx) | |-------|------|-------|--------|-------------------| | cx11 | 1 | 2 GB | 20 GB | β¬4 | | cx21 | 2 | 4 GB | 40 GB | β¬6 | | cx22 | 2 | 4 GB | 40 GB | β¬6 (deprecated) | | cx23 | 2 | 4 GB | 40 GB | β¬3 | | cx31 | 2 | 8 GB | 80 GB | β¬10 | | cx33 | 4 | 8 GB | 80 GB | β¬5 | | cpx11 | 2 | 2 GB | 40 GB | β¬5 | | cpx21 | 3 | 4 GB | 80 GB | β¬10 | | cpx31 | 4 | 8 GB | 160 GB | β¬18 |
cx series: Shared vCPU (cost-optimized) cpx series: Dedicated vCPU (performance-optimized)
Tips
--output json for parsing: hcloud server list --output json | jq~/.config/hcloud/cli.toml for different projects/accounts--labels environment=production,project=webhcloud context config default-location nbg1--dry-run or --validate flagsDocumentation
Official docs: https://docs.hetzner.cloud/ GitHub: https://github.com/hetznercloud/cli
βοΈ Configuration
Installation (if not already installed):
# Detect architecture
ARCH=$(uname -m)
if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
URL="https://github.com/hetznercloud/cli/releases/latest/download/hcloud-linux-arm64.tar.gz"
else
URL="https://github.com/hetznercloud/cli/releases/latest/download/hcloud-linux-amd64.tar.gz"
fiInstall
cd /tmp
wget -q "$URL"
tar xzf hcloud-linux-*.tar.gz
sudo mv hcloud /usr/local/bin/
chmod +x /usr/local/bin/hcloud
Configuration (first time):
mkdir -p ~/.config/hcloud
cat > ~/.config/hcloud/cli.toml <[[contexts]]
name = "default"
token = "YOUR_HETZNER_API_TOKEN"
EOF
chmod 600 ~/.config/hcloud/cli.toml
Verify:
hcloud version
hcloud server list
π Tips & Best Practices
--output json for parsing: hcloud server list --output json | jq~/.config/hcloud/cli.toml for different projects/accounts--labels environment=production,project=webhcloud context config default-location nbg1--dry-run or --validate flags