- Installing OpenTofu
- .deb-based Linux (Debian, Ubuntu)
Installing OpenTofu on .deb-based Linux (Debian, Ubuntu, etc.)
Thank you to for sponsoring the OpenTofu package hosting.
OpenTofu is distributed in the .deb package format on Packagecloud. You can install it using a convenience script or by following the step-by-step instructions below.
Installing using the convenience script
You can install OpenTofu using the convenience script with the following commands:
curl --proto '=https' --tlsv1.2 -fsSL 'https://packages.opentofu.org/install/repositories/opentofu/tofu/script.deb.sh?any=true' -o /tmp/tofu-repository-setup.sh
# Inspect the downloaded script at /tmp/tofu-repository-setup.sh before running
sudo bash /tmp/tofu-repository-setup.sh
rm /tmp/tofu-repository-setup.sh
sudo apt-get install tofu
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 https://packages.opentofu.org/opentofu/tofu/gpgkey | sudo gpg --no-tty --batch --dearmor -o /etc/apt/keyrings/opentofu.gpg
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] https://packages.opentofu.org/opentofu/tofu/any/ any main
deb-src [signed-by=/etc/apt/keyrings/opentofu.gpg] https://packages.opentofu.org/opentofu/tofu/any/ 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