Skip to main content

Installing OpenTofu on .deb-based Linux (Debian, Ubuntu, etc.)

Thank you to Buildkite for sponsoring the OpenTofu package hosting.

You can install OpenTofu from our Debian repository by following the step-by-step instructions below.

Installing using the installer

You can use the OpenTofu installer script to run the installation.

# Download the installer script:
curl --proto '=https' --tlsv1.2 -fsSL -o
# Alternatively: wget --secure-protocol=TLSv1_2 --https-only -O

# Give it execution permissions:
chmod +x

# Please inspect the downloaded script

# Run the installer:
./ --install-method deb

# Remove the installer:

Step-by-step instructions

The following steps explain how to set up the OpenTofu Debian repositories. These instructions should work on most Debian-based Linux systems.

Installing tooling

In order to add the repositories, you will need to install some tooling. On most Debian-based operating systems, these tools will already be installed.

sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg

Set up the OpenTofu repository

First, you need to make sure you have a copy of the OpenTofu GPG key. This verifies that your packages have indeed been created using the official pipeline and have not been tampered with.

sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL | sudo tee /etc/apt/keyrings/opentofu.gpg >/dev/null
curl -fsSL | sudo gpg --no-tty --batch --dearmor -o /etc/apt/keyrings/opentofu-repo.gpg >/dev/null
sudo chmod a+r /etc/apt/keyrings/opentofu.gpg

Now you have to create the OpenTofu source list.

echo \
"deb [signed-by=/etc/apt/keyrings/opentofu.gpg,/etc/apt/keyrings/opentofu-repo.gpg] any main
deb-src [signed-by=/etc/apt/keyrings/opentofu.gpg,/etc/apt/keyrings/opentofu-repo.gpg] any main" | \
sudo tee /etc/apt/sources.list.d/opentofu.list > /dev/null

Installing OpenTofu

Finally, you can install OpenTofu:

sudo apt-get update
sudo apt-get install -y tofu