如何安装 Tor

These instructions are meant for installing tor the network daemon i.e. little-t tor. For instructions to install Tor Browser, refer to the Tor Browser user manual.

查看:

不要使用 Ubuntu Universe 源中的软件包。 过去它们没有可靠地进行更新。 这意味着您可能错过稳定性和安全性的修复。

Tor Project 维护着它自己的 Debian 软件包存储库。由于 Debian 提供 Tor 的 LTS 版本,这可能并不是最新的 Tor 稳定版本。因此,我们建议您从我们的软件包存储库中安装 Tor

在基于 Debian 的系统中,如何添加 Tor 软件包仓库?请查看以下指示:

前提:验证 CPU 架构

The package repository offers amd64 and arm64 binaries. Verify your operating system is capable of running the binary by inspecting the output of the following command:

$ sudo dpkg --print-architecture

It should output either amd64 or arm64. The repository does not support other CPU architectures.

1. 安装 apt-transport-https

使所有使用 libapt-pkg 库的软件包管理器通过 https(安全超文本传输协议)访问的源中提供的元数据和软件包。

$ sudo apt install apt-transport-https

2. Create a new file in /etc/apt/sources.list.d/ named tor.sources and add the following entry:

Types: deb deb-src
URIs: https://deb.torproject.org/torproject.org/
Suites: <DISTRIBUTION>
Components: main
Signed-By: /usr/share/keyrings/deb.torproject.org-keyring.gpg

If you want to try experimental packages, add this stanza in addition to the lines above:

Types: deb deb-src
URIs: https://deb.torproject.org/torproject.org/
Suites: tor-experimental-<DISTRIBUTION>
Components: main
Signed-By: /usr/share/keyrings/deb.torproject.org-keyring.gpg

For nightly builds, add the following:

Types: deb deb-src
URIs: https://deb.torproject.org/torproject.org/
Suites: tor-nightly-main-<DISTRIBUTION>
Components: main
Signed-By: /usr/share/keyrings/deb.torproject.org-keyring.gpg

Replace <DISTRIBUTION> with your operating system's codename. You can run lsb_release -c or check /etc/os-release to find it.

If you add multiple entries to your file, make sure to add at least one empty line between each entry.

Note: The tor.sources file shown above uses the deb822 format, which is supported by APT 1.1 and later. If you're using an older version of APT (typically found on older Debian or Ubuntu releases), this format may not be supported. In that case, you can instead add the following to a tor.list file in /etc/apt/sources.list.d/ to achieve the same result.

deb     [signed-by=/usr/share/keyrings/deb.torproject.org-keyring.gpg] https://deb.torproject.org/torproject.org <DISTRIBUTION> main
deb-src [signed-by=/usr/share/keyrings/deb.torproject.org-keyring.gpg] https://deb.torproject.org/torproject.org <DISTRIBUTION> main

3. 如果尚未安装 GnuPG,请安装:

$ sudo apt install gnupg

4. 然后通过在命令提示符下运行以下命令来添加用于签署软件包的 gpg 密钥:

$ wget -qO- https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | gpg --dearmor | sudo tee /usr/share/keyrings/deb.torproject.org-keyring.gpg >/dev/null

5. 安装 tor 和 tor debian 密钥环

推荐使用我们提供的 Debian 软件包,以便保持签名密钥为最新。请使用以下命令安装:

$ sudo apt update
$ sudo apt install tor deb.torproject.org-keyring

Tor Project 在 CentOS 、RHEL 和 Fedora 系统上维护自己的 RPM 安装包存储库

下面是 CentOS、RHEL 和 Fedora 系统使用 Tor 安装包储存库的方法:

1. 使用 epel 存储库(只针对 CentOS 和 RHEL 系统)

‪$ sudo dnf install epel-release -y

2. 在 /etc/yum.repos.d/tor.repo 中加入以下内容

对于与 CentOS 和 RHEL 系统:

[tor] name=Tor for Enterprise Linux $releasever - $basearch baseurl=https://rpm.torproject.org/centos/$releasever/$basearch enabled=1 gpgcheck=1 gpgkey=https://rpm.torproject.org/centos/public_gpg.key cost=100

对于 Fedora:

[tor] name=Tor for Fedora $releasever - $basearch baseurl=https://rpm.torproject.org/fedora/$releasever/$basearch enabled=1 gpgcheck=1 gpgkey=https://rpm.torproject.org/fedora/public_gpg.key cost=100

3. 安装 Tor 安装包

然后你可以安装最新版的 Tor 软件包。

$ sudo dnf install tor -y

首次使用时,你需要导入 GPG 公钥。

Importing GPG key 0x3621CD35: Userid : "Kushal Das (RPM Signing key) kushal@torproject.org" Fingerprint: 999E C8E3 14BC 8D46 022D 6C7D E217 C30C 3621 CD35 From : https://rpm.torproject.org/fedora/public_gpg.key Is this ok [y/N]: y

要在 Void Linux 上安装 tor 包,请运行:

# xbps-install -S tor

要在 Arch Linux 上安装 tor 包,请运行:

# pacman -Syu tor

To install the tor package on FreeBSD, run:

# pkg install tor

To install the tor package on OpenBSD, run:

# pkg_add tor

安装 pkg_add

NetBSD 操作系统的现代版本可以设置为使用 pkgin,这是一款旨在像 aptyum 一样管理 pkgsrc 二进制包的软件。我们在此处不讨论它的安装,而是选择使用普通的 pkg_add

# echo "PKG_PATH=http://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/$(uname -m)/$(uname -r)/All" > /etc/pkg_install.conf

软件包安装

安装 tor NetBSD 的软件包:

# pkg_add tor

引导 pkg

DragonFlyBSD 的每日快照和发行版(从 3.4 开始)已安装了 pkg。但是,从较早的版本中升级将没有。如果由于任何原因在系统上缺少 pkg,则可以快速引导,而无需从源代码构建,甚至无需安装 DPorts

# cd /usr
# make pkg-bootstrap
# rehash
# pkg-static install -y pkg
# rehash

安装 pkg 的推荐步骤

此处与我们在 FreeBSD 系统上的情况类似,我们将使用 HTTPS 来获取我们的包和更新。所以此处我们还需要一个额外的包来帮助我们(ca_root_nss)。

安装 ca_root_nss 软件包:

# pkg install ca_root_nss

对于全新安装,会把文件 /usr/local/etc/pkg/repos/df-latest.conf.sample 复制到 /usr/local/etc/pkg/repos/df-latest。会忽略以“.sample”扩展结尾的文件;pkg(8) 仅读取以“.conf”结尾的文件,并且会读取找到的所有文件。

DragonFlyBSD 有 2 个软件包存储库:

  • Avalon (mirror-master.dragonflybsd.org);
  • Wolfpond (pkg.wolfpond.org).

我们可以简单地编辑用于指出 /usr/local/etc/pkg/repos/df-latest 上的存储库的 URL,就这样!记得对 Avalon 使用 pkg+https://

应用所有这些更改后,我们再次更新软件包列表,并尝试检查是否已有新的更新要应用:

# pkg update -f
# pkg upgrade -y -f

软件包安装

安装 tor 软件包:

# pkg install tor