Skip to main content
πŸ“¬ Get weekly Production AI insights Practical notes on Kubernetes, AI infrastructure and platform engineering. No spam. Subscribe free
DevOps

Install Terraform on Debian 12: Complete Guide (2026)

Install Terraform on Debian 12 in 2026. Official repository setup, package installation, post-install configuration, and troubleshooting.

Luca Berton

Β· AI Advisor & Architect

Published Β· 1 min read

Here is how to install Terraform on Debian 12. Tested and verified.

Prerequisites

  • Debian 12 installed and updated
  • Root or sudo access
  • Internet connection

Step 1: Update System

sudo apt update && sudo apt upgrade -y

Step 2: Add Official Repository

Terraform is distributed through HashiCorp’s official apt repository. Import the signing key and register the repository before installing:

# Install prerequisites for adding a signed apt repository
sudo apt install -y wget gnupg

# Import the HashiCorp GPG signing key
wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg

# Add the official HashiCorp repository (resolves to "bookworm" on Debian 12)
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(grep -oP '(?<=UBUNTU_CODENAME=).*' /etc/os-release || lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list

sudo apt update

Step 3: Install Terraform

sudo apt install -y terraform

Step 4: Verify Installation

terraform version

Expected output should show the installed version, for example Terraform v1.x.x.

Step 5: Enable Shell Autocomplete

Terraform is a CLI binary with no background service, so there is nothing to enable or start with systemd. Instead, enable tab-completion for your shell:

terraform -install-autocomplete

This appends the completion hook to your shell profile (~/.bashrc for Bash). Restart your shell or run source ~/.bashrc for it to take effect.

Troubleshooting

GPG Key Import Failure

If apt update reports NO_PUBKEY or a signature verification error, the keyring file may be missing or empty. Re-run the key import and confirm the file exists:

ls -l /usr/share/keyrings/hashicorp-archive-keyring.gpg
wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
sudo apt update

Package Not Found

Confirm the repository was registered and refresh the apt cache:

cat /etc/apt/sources.list.d/hashicorp.list
sudo apt update
apt-cache policy terraform

If apt-cache policy terraform shows no install candidate, double-check that the codename in hashicorp.list matches Debian 12’s codename (bookworm).

Uninstall

sudo apt remove -y terraform

About the Author

I am Luca Berton, AI and Cloud Advisor. Book a consultation to get help with your infrastructure setup.

Free 30-min Production AI consultation

Book Now