Skip to main content

Hetzner Cloud CLI

362 words·
Hetzner Cloud
Table of Contents

Hetzner Cloud CLI Installation (Deb)
#

# Download the latest hetznercli binary
wget https://github.com/hetznercloud/cli/releases/latest/download/hcloud-linux-amd64.tar.gz

# Extract the binary
tar -xzf hcloud-linux-amd64.tar.gz

# Move the binary to system-wide binary directory
sudo mv hcloud /usr/local/bin/

# Remove tar file
rm hcloud-linux-amd64.tar.gz LICENSE  README.md
# Verify installation
hcloud version

# Help / list commands
hcloud



CLI Context
#

Add a Context
#

Create an API token for a Hetzner Cloud project: https://console.hetzner.cloud/

# Create a new context
hcloud context create example-project

# Shell output:
Token: # Paste the project token
Context example-project created and activated

Verify Current Context
#

# List the current / active context
hcloud context list

# Shell output:
ACTIVE   NAME
*        example-project

Switch Context
#

# Switch context
hcloud context use context-name

Remove Context
#

# Delete context
hcloud context delete example-project



CLI Commands
#

List VM Types
#

# List available VM types
hcloud server-type list

# Shell output:
ID    NAME    CORES   CPU TYPE    ARCHITECTURE   MEMORY     DISK     STORAGE TYPE
22    cpx11   2       shared      x86            2.0 GB     40 GB    local
23    cpx21   3       shared      x86            4.0 GB     80 GB    local
24    cpx31   4       shared      x86            8.0 GB     160 GB   local
25    cpx41   8       shared      x86            16.0 GB    240 GB   local
26    cpx51   16      shared      x86            32.0 GB    360 GB   local
45    cax11   2       shared      arm            4.0 GB     40 GB    local
93    cax21   4       shared      arm            8.0 GB     80 GB    local
94    cax31   8       shared      arm            16.0 GB    160 GB   local
95    cax41   16      shared      arm            32.0 GB    320 GB   local
96    ccx13   2       dedicated   x86            8.0 GB     80 GB    local
97    ccx23   4       dedicated   x86            16.0 GB    160 GB   local
98    ccx33   8       dedicated   x86            32.0 GB    240 GB   local
99    ccx43   16      dedicated   x86            64.0 GB    360 GB   local
100   ccx53   32      dedicated   x86            128.0 GB   600 GB   local
101   ccx63   48      dedicated   x86            192.0 GB   960 GB   local
104   cx22    2       shared      x86            4.0 GB     40 GB    local
105   cx32    4       shared      x86            8.0 GB     80 GB    local
106   cx42    8       shared      x86            16.0 GB    160 GB   local
107   cx52    16      shared      x86            32.0 GB    320 GB   local

Servers
#

# List servers of the project
hcloud server list