Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Install OpenTofu

Steps

Run the command chain below to add the custom repository before using it to install the tofu package.

sudo apt update \
  && sudo apt install -y apt-transport-https ca-certificates curl gnupg \
  && curl -fsSL https://get.opentofu.org/opentofu.gpg | sudo tee /etc/apt/keyrings/opentofu.gpg >/dev/null \
  && curl -fsSL https://packages.opentofu.org/opentofu/tofu/gpgkey | sudo gpg --no-tty --batch --dearmor -o /etc/apt/keyrings/opentofu-repo.gpg >/dev/null \
  && sudo chmod a+r /etc/apt/keyrings/opentofu.gpg /etc/apt/keyrings/opentofu-repo.gpg \
  && echo "deb [signed-by=/etc/apt/keyrings/opentofu.gpg,/etc/apt/keyrings/opentofu-repo.gpg] https://packages.opentofu.org/opentofu/tofu/any/ any main 
deb-src [signed-by=/etc/apt/keyrings/opentofu.gpg,/etc/apt/keyrings/opentofu-repo.gpg] https://packages.opentofu.org/opentofu/tofu/any/ any main" | \
  sudo tee /etc/apt/sources.list.d/opentofu.list > /dev/null \
  && sudo chmod a+r /etc/apt/sources.list.d/opentofu.list \
  && sudo apt update \
  && sudo apt install -y tofu

This worked on Debian 13 and installed OpenTofu v1.12.6 at the time of updating this post.

References

Last updated: 24th August 2026
First published: 16th November 2023

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch