- 入门
- 安装 OpenTofu
- 基于 .deb 的 Linux(Debian、Ubuntu)
在基于 .deb 的 Linux 系统(Debian、Ubuntu 等)上安装 OpenTofu
您可以按照以下分步说明从我们的 Debian 仓库安装 OpenTofu。
使用安装程序安装
您可以使用 OpenTofu 安装程序脚本来运行安装。
# 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 deb
# Remove the installer:
rm -f install-opentofu.sh
分步说明
以下步骤说明了如何设置 OpenTofu Debian 仓库。这些说明应该适用于大多数基于 Debian 的 Linux 系统。
安装工具
为了添加仓库,您需要安装一些工具。在大多数基于 Debian 的操作系统中,这些工具已经安装。
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg
设置 OpenTofu 仓库
首先,您需要确保您拥有 OpenTofu GPG 密钥的副本。这可以验证您的软件包确实已使用官方管道创建,并且未被篡改。
sudo install -m 0755 -d /etc/apt/keyrings
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
现在您需要创建 OpenTofu 源列表。
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
安装 OpenTofu
最后,您可以安装 OpenTofu
sudo apt-get update
sudo apt-get install -y tofu