This tutorial will guide you through the process of setting up the hcloud CLI on your local machine.
Before you begin, ensure you have the following:
You can download pre-built binaries from our GitHub releases.
Install them by extracting the archive and moving the binary to a directory in your PATH.
On a 64-bit Linux system, it could look something like this:
curl -sSLO https://github.com/hetznercloud/cli/releases/latest/download/hcloud-linux-amd64.tar.gz
sudo tar -C /usr/local/bin --no-same-owner -xzf hcloud-linux-amd64.tar.gz hcloud
rm hcloud-linux-amd64.tar.gzIf you have Go installed, you can also install hcloud CLI from source using the following command:
go install github.com/hetznercloud/cli/cmd/hcloud@latestNote
Binaries built with Go will not have the correct version embedded.
Note
Both of the above installation methods do not provide automatic updates. Please make sure to keep your installation up to date manually.
Warning
Debian packages are experimental and might change or break in the future.
On Debian and Ubuntu-based distributions, you can install the hcloud CLI using the .deb package:
-
Download the latest
.debpackage from the GitHub releases page. -
Install the package using
dpkg:
# Download the package (replace with the actual version and architecture)
curl -sSLO https://github.com/hetznercloud/cli/releases/latest/download/hcloud-cli_<version>_linux_amd64.deb
# Install the package
sudo dpkg -i hcloud-cli_<version>_linux_amd64.debThe .deb package includes shell completions for bash, zsh, and fish, as well as man pages.
Warning
RPM packages are experimental and might change or break in the future.
On Fedora, RHEL, CentOS, and other RPM-based distributions, you can install the hcloud CLI using the .rpm package:
-
Download the latest
.rpmpackage from the GitHub releases page. -
Install the package using
rpmordnf:
# Download the package (replace with the actual version and architecture)
curl -sSLO https://github.com/hetznercloud/cli/releases/latest/download/hcloud-cli-<version>-1.x86_64.rpm
# Install using dnf (Fedora/RHEL 8+/CentOS 8+)
sudo dnf install hcloud-cli-<version>-1.x86_64.rpm
# Or install using rpm
sudo rpm -i hcloud-cli-<version>-1.x86_64.rpmThe .rpm package includes shell completions for bash, zsh, and fish, as well as man pages.
On Linux and macOS you can also install the hcloud CLI using Homebrew:
brew install hcloudWarning
The WinGet and Scoop package entries are not maintained by Hetzner.
On Windows, you can install hcloud using WinGet (Windows Package Manager) or Scoop:
winget install HetznerCloud.CLIscoop install hcloudInstead of installing hcloud on the host, you can also use our docker image at hetznercloud/cli.
docker run --rm -e HCLOUD_TOKEN="<your token>" hetznercloud/cli:latest <command>If you want to use (and persist) your configuration, you can mount it to /config.toml:
docker run --rm -v ~/.config/hcloud/cli.toml:/config.toml hetznercloud/cli:latest <command>The image is based on Alpine Linux, so a shell is available in the image. You can use it to run commands interactively:
docker run -it --rm --entrypoint /bin/sh hetznercloud/cli:latestWarning
Some third-party package repositories may provide outdated versions of the hcloud CLI. Please consider one of the other installation methods.
hcloud CLI offers auto-completion for bash, zsh, fish and PowerShell. It is recommended to enable it for a better user experience.
To load completions into the current shell execute:
source <(hcloud completion bash)
In order to make the completions permanent, append the line above to your .bashrc.
If shell completions are not already enabled for your environment need to enable them. Add the following line to your ~/.zshrc file:
autoload -Uz compinit; compinit
To load completions for each session execute the following commands:
mkdir -p ~/.config/hcloud/completion/zsh
hcloud completion zsh > ~/.config/hcloud/completion/zsh/_hcloud
Finally add the following line to your ~/.zshrc file, before you call the compinit function:
fpath+=(~/.config/hcloud/completion/zsh)
In the end your ~/.zshrc file should contain the following two lines in the order given here.
fpath+=(~/.config/hcloud/completion/zsh)
# ... anything else that needs to be done before compinit
autoload -Uz compinit; compinit
# ...
You will need to start a new shell for this setup to take effect.
To load completions into the current shell execute:
hcloud completion fish | source
In order to make the completions permanent execute once:
hcloud completion fish > ~/.config/fish/completions/hcloud.fish
To load completions into the current shell execute:
PS> hcloud completion powershell | Out-String | Invoke-Expression
To load completions for every new session, run and source this file from your PowerShell profile.
PS> hcloud completion powershell > hcloud.ps1
The hcloud CLI uses contexts to manage multiple Hetzner Cloud tokens and set configuration preferences.
First, you need to create an API token. Follow the instructions in the Hetzner Cloud documentation to create your project API token.
Once you have your token, you can create a context using the following command:
hcloud context create <context-name>Ideally, keep the context name similar to the project name so you can easily identify it later.
When prompted, enter the API token you created earlier. Your context should now be created and activated.
To verify that the hcloud CLI is working correctly, you can run the following command:
hcloud datacenter listYou should see something like this:
ID NAME DESCRIPTION LOCATION
2 nbg1-dc3 Nuremberg 1 virtual DC 3 nbg1
3 hel1-dc2 Helsinki 1 virtual DC 2 hel1
4 fsn1-dc14 Falkenstein 1 virtual DC 14 fsn1
5 ash-dc1 Ashburn virtual DC 1 ash
6 hil-dc1 Hillsboro virtual DC 1 hil
7 sin-dc1 Singapore virtual DC 1 sin
If you see this output, congratulations! You have successfully set up the hcloud CLI on your local machine.
If there are any problems, make sure you followed all steps of this tutorial correctly. If there still are problems, you can reach out to our Support to get help.