setting up hetzner cloud on macOS

set up and manage Hetzner Cloud servers on macOS

· by Aron Kovacs

1. install hcloud CLI

Install the Hetzner Cloud CLI tool using Homebrew:

brew install hcloud
2. create API token

To interact with the Hetzner Cloud API, follow these steps:

  1. Go to the Hetzner Cloud Console and log in
  2. Create a new project or select an existing one
  3. Navigate to Security → API Tokens
  4. Create a new token with read & write permissions
3. configure hcloud CLI

Set up your CLI with the API token:

hcloud context create my-project

You will be prompted to enter your API token.

4. create SSH key

Generate an SSH key pair if you don't have one:

ssh-keygen -t rsa -b 4096 -C "apple.aron@gmail.com"

Add the SSH key to Hetzner Cloud:

  1. Go to SSH Keys in the Hetzner Cloud Console
  2. Click Add SSH Key
  3. Paste the contents of your ~/.ssh/id_rsa.pub file
5. create a server

Check available server images:

hcloud image list

Create a server with your chosen configuration:

hcloud server create --name my-server --type cx22 --image ubuntu-20.04 --ssh-key my-ssh-key
6. access your server

Connect to your server via SSH:

ssh root@my-server-ip
Note: Always keep your API token secure and never share it publicly. Replace the example values (server IP, SSH key name, etc.) with your actual values.