Skip to main content

Installing OpenTofu on RHEL, openSUSE, AlmaLinux and other RPM-based distributions

Thank you to Buildkite for sponsoring the OpenTofu package hosting.

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

Installing using the installer

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

Code Block
# Download the installer script:
curl --proto '=https' --tlsv1.2 -fsSL https://get.opentofu.org/install-opentofu.sh -o install-opentofu.sh
# Alternatively: wget --secure-protocol=TLSv1_2 --https-only https://get.opentofu.org/install-opentofu.sh -O install-opentofu.sh

# Give it execution permissions:
chmod +x install-opentofu.sh

# Please inspect the downloaded script

# Run the installer:
./install-opentofu.sh --install-method rpm

# Remove the installer:
rm install-opentofu.sh

Step-by-step instructions

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

Adding the OpenTofu repository

Create the /etc/yum.repos.d/opentofu.repo file by running the following command:

Code Block
cat >/etc/yum.repos.d/opentofu.repo <<EOF
[opentofu]
name=opentofu
baseurl=https://packages.opentofu.org/opentofu/tofu/rpm_any/rpm_any/\$basearch
repo_gpgcheck=0
gpgcheck=1
enabled=1
gpgkey=https://get.opentofu.org/opentofu.gpg
https://packages.opentofu.org/opentofu/tofu/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300

[opentofu-source]
name=opentofu-source
baseurl=https://packages.opentofu.org/opentofu/tofu/rpm_any/rpm_any/SRPMS
repo_gpgcheck=0
gpgcheck=1
enabled=1
gpgkey=https://get.opentofu.org/opentofu.gpg
https://packages.opentofu.org/opentofu/tofu/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
EOF

Installing OpenTofu

Now you install OpenTofu by running:

Code Block
sudo yum install -y tofu