Little-t-tor

注意:这些说明用于安装 tor 网络守护程序,即 little-t-tor 有关安装 Tor 浏览器的说明,请参阅 Tor 浏览器用户手册

管理员权限:要安装 Tor,您需要 root 权限。 以下所有需要以 root 用户身份运行的命令,如 apt 和 dpkg,都将在前面加上 #,而作为用户运行的命令则用 $ (也就是终端中的标准提示符)表示。

Debian / Ubuntu

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

配置 Tor 软件包存储库。

按照说明启用 Tor Project 的 APT 存储库。

软件包安装

# apt install tor

Fedora

配置 Tor 软件包存储库

按照说明启用 Tor Project 的 RPM 软件包存储库。

软件包安装

# dnf install tor

FreeBSD

软件包安装

# pkg install tor

OpenBSD

软件包安装

# pkg_add tor

macOS

安装包管理器

在 OS X 上有两个软件包管理器:Homebrew 和 Macports。 您可以使用您选择的软件包管理器。

要安装 Homebrew,请按照 brew.sh 上的说明进行操作。

要安装 Macports,请按照 macports.org 上的说明操作。

软件包安装

如果你在终端窗口中使用 Homebrew,请运行:

# brew install tor

如果您在终端窗口中使用 Macports,请运行:

$ sudo port install tor

Arch Linux

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

# pacman -Syu tor

DragonFlyBSD

引导 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

NetBSD

安装 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

Void Linux

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

# xbps-install -S tor

从源代码安装 Tor

下载最新版本和依赖

Tor 的最新版本可在下载页面找到。

如果你正在从源代码构建,请先安装 libevent,并确保你已经安装了 openssl 和 zlib(包括适用的-devel 软件包)。

安装 tor

tar -xzf tor-<version>.tar.gz; cd tor-<version>

<version> 替换为 tor 的最新版本,例如 tor-0.4.8.12

./configure && make

现在你可以将 tor 作为 src/app/tor 运行(0.4.3.x及更高版本),或者你可以运行make install(如果需要请以 root 身份运行)将其安装到 /usr/local/ 中,然后只需运行 tor 即可启动它。

注意:这些指南是为了验证 Tor 源代码。 请按照正确的指示来验证 Tor 浏览器的签名

数字签名用于确保某个程序包有其开发者生产并且没有被篡改。 下面我们解释为什么它很重要,以及如何验证你下载的 tor 源代码是我们创建的,没有被某些攻击者修改。

我们下载页面上的每个文件都附带两个文件,标签为“校验和”和“签名”,其名称与软件包相同,扩展名分别为“.sha256sum”和“.sha256sum.asc”。

.asc 文件将验证 .sha256sum 文件(包含软件包的校验和)没有被篡改。一旦签名被验证有效(见下面的方法),软件包的完整性就可以用以下方法验证:

$ sha256sum -c *.sha256sum

这些文件用于验证你所下载的文件正是我们希望你得到的文件。 一般来说,你可以通过右击 “签名”和“校验和”链接并选择“另存为”选项来下载该文件,不过这可能因网络浏览器而异。

例如,tor-0.4.6.7.tar.gz配有文件tor-0.4.6.7.tar.gz.sha256sum.asc。 这些是示例文件名,并下载文件不会完全相同。

下面将解释如何在不同的操作系统上验证下载文件的数字签名。 请注意,数字签名的日期指对程序包进行签名的时间。 因此,每次新文件上传时,将生产新的签名,并且日期不同。 只要你验证了签名,不必担心报告的日期可能有所不同。

安装 GnuPG

首先,验证签名之前,你需要安装 GnuPG。

对于 Windows 的用户:

如果使用 Windows,请下载 Gpg4win 并运行安装包。

为了验证签名,你需要在 Windows 命令行(cmd.exe)中输入一些命令。

对于 macOS 的用户:

如果使用 macOS,你可以安装 GPGTools

为了验证签名,你需要在终端(位于“应用程序”下)中输入一些命令。

对于 GNU/Linux 的用户:

如果使用 GNU/Linux,那么系统大概已安装 GnuPG,因为大多数 Linux 发行版都预装了该软件。

为了验证签名,你需要在 windows 命令行中输入几个命令。 如何做到这一点,将取决于你的发行版。

提取 Tor 开发者密钥

下面的密钥可以对 tarball 签名。不要期望都有签名,这可能取决于谁来发布。

可通过上述链接获得密钥,或通过:

$ gpg --auto-key-locate nodefault,wkd --locate-keys ahf@torproject.org
$ gpg --auto-key-locate nodefault,wkd --locate-keys dgoulet@torproject.org
$ gpg --auto-key-locate nodefault,wkd --locate-keys nickm@torproject.org

这应该显示类似结果(对于 Nickm):

gpg: key FE43009C4607B1FB: public key "Nick Mathewson <nickm@torproject.org>" imported
gpg: Total number processed: 1
gpg:               imported: 1
pub   rsa4096 2016-09-21 [C] [expires: 2025-10-04]
      2133BC600AB133E1D826D173FE43009C4607B1FB
uid           [ unknown] Nick Mathewson <nickm@torproject.org>
sub   rsa4096 2016-09-23 [S] [expires: 2025-10-04]
sub   rsa4096 2016-09-23 [E] [expires: 2025-10-04]

如果看到错误信息,那就是出了问题,你不能继续下去,直到你弄清楚为什么这不行。 也许可以使用 其他方法(使用公钥)部分来导入密钥。

导入密钥后,你可以将其保存到文件中(此处提供其指纹来指定):

$ gpg --output ./tor.keyring --export 0x2133BC600AB133E1D826D173FE43009C4607B1FB

该命令将密钥保存在路径为./tor.keyring的文件中,即当前目录。 如果运行这个命令后 ./tor.keyring不存在,就说明出了问题,不能继续操作,直到你弄清楚为什么出现错误。

验证签名

要验证你下载的软件包的签名,你需要下载相应的 .sha256sum.asc 签名文件和 .sha256sum 文件,并通过命令要求 GnuPG 验证你下载的文件来验证它。

以下示例假设已在“Downloads”文件中下载这两个文件。 请注意,这些命令使用示例文件名,而实际文件名是不同的:你下载的版本与 9.0 不同,并且没有选择英文(en-US)版本。

对于 Windows 的用户:

gpgv --keyring .\tor.keyring Downloads\tor-0.4.6.10.tar.gz.sha256sum.asc Downloads\tor-0.4.6.10.tar.gz.sha256sum

对于 macOS 的用户:

gpgv --keyring ./tor.keyring ~/Downloads/tor-0.4.6.10.tar.gz.sha256sum.asc ~/Downloads/tor-0.4.6.10.tar.gz.sha256sum

对于 BSD/Linux 用户:

gpgv --keyring ./tor.keyring ~/Downloads/tor-0.4.6.10.tar.gz.sha256sum.asc ~/Downloads/tor-0.4.6.10.tar.gz.sha256sum

该命令的结果应该产生这样的结果(取决于签名用的哪个密钥):

gpgv: Signature made Mon 16 Aug 2021 04:44:27 PM -03
gpgv:                using RSA key 7A02B3521DC75C542BA015456AFEE6D49E92B601
gpgv: Good signature from "Nick Mathewson <nickm@torproject.org>"

如果错误消息含有“No such file or directory”,上述某个步骤出错,或者未更改命令中的示例文件名。

另外,你可能想要了解更多 GnuPG 信息

验证校验和

现在我们验证了校验和的签名,接着需要验证软件包的完整性。

对于 Windows 的用户:

certUtil -hashfile tor-0.4.6.10.tar.gz.sha256sum SHA256

对于 macOS 的用户:

shasum -a 256 tor-0.4.6.10.tar.gz.sha256sum

对于 BSD/Linux 用户:

sha256sum -c tor-0.4.6.10.tar.gz.sha256sum

Attention: These instructions are meant for using pluggable transports with tor, the network daemon i.e. little-t tor. 有关在 Tor 浏览器中使用可插拔传输的说明,请参阅 Tor 浏览器用户手册

有时可能会阻止直接访问 Tor 网络。 Tor 可以与称为可插拔传输的规避工具一起使用,以绕过这些阻止。 obfs4Snowflake 和 WebTunnel 是一些可与 Tor 一起使用的可插拔传输。 Tor can be configured to use pluggable transports by modifying Tor's configuration file i.e. torrc.

Steps to configure tor to use pluggable transports for different operating systems are as follows.

  • Download and install tor or the Tor Expert Bundle for your operating system. If access to the Tor Project website is blocked, use an official Tor Project mirror.

  • If you have tor installed, pluggable transport binaries can be downloaded as part of the Tor Expert Bundle. Pluggable transport binaries available as part of the Tor Expert Bundle:

    • lyrebird : implements several pluggable transport protocols, including obfs4 and WebTunnel.
    • snowflake-client : implements the Snowflake pluggable transport.
  • 将 Tor 专家包解压到您选择的目录中。

  • 对于可插拔传输,obfs4 和 WebTunnel,可从网桥网站、通过电子邮件Telegram 获取网桥

  • Modify Tor's configuration file, i.e. torrc. Copy and modify the following sample torrc according to the operating system. If you have installed little-t tor on Linux, you will have to modify the default torrc.

配置 tor 使用 obfs4 或 WebTunnel

UseBridges 1
# Uncomment the line below for Windows and include the path to the pluggable transport executable (Example: C:\Users\user\Downloads\tor\pluggable_transports\lyrebird.exe)
#ClientTransportPlugin meek_lite,obfs4,webtunnel exec <path-of-executable>

# Uncomment the line below for macOS and include the path to the pluggable transport executable (Example: /Users/user/Downloads/tor/pluggable_transports/lyrebird)
#ClientTransportPlugin meek_lite,obfs4,webtunnel exec <path-of-executable>

# Uncomment the line below for Linux and include the path to the pluggable transport executable (Example: /home/user/Downloads/tor/pluggable_transports/lyrebird)
#ClientTransportPlugin meek_lite,obfs4,webtunnel exec <path-of-executable>

Bridge obfs4 <IP ADDRESS>:<PORT> <FINGERPRINT> cert=<CERTIFICATE> iat-mode=0
Bridge webtunnel <IP ADDRESS>:<PORT> <FINGERPRINT> url=<URL> ver=0.0.1

配置 tor 使用 Snowflake

UseBridges 1
# Uncomment the line below for Windows and include the path to the pluggable transport executable (Example: C:\username\Browser\TorBrowser\tor\pluggable_transports\snowflake-client.exe)
#ClientTransportPlugin snowflake exec <path-of-executable>

# Uncomment the line below for macOS and include the path to the pluggable transport executable (Example: /Users/user/Downloads/tor/pluggable_transports/snowflake-client)
#ClientTransportPlugin snowflake exec <path-of-executable>

# Uncomment the line below for Linux and include the path to the pluggable transport executable (Example: /home/user/Downloads/tor/pluggable_transports/snowflake-client)
#ClientTransportPlugin snowflake exec <path-of-executable>

Bridge snowflake 192.0.2.3:80 2B280B23E1107BB62ABFC40DDCC8824814F80A72 fingerprint=2B280B23E1107BB62ABFC40DDCC8824814F80A72 url=https://1098762253.rsc.cdn77.org front=www.phpmyadmin.net,cdn.zk.mk ice=stun:stun.antisip.com:3478,stun:stun.epygi.com:3478,stun:stun.uls.co.za:3478,stun:stun.voipgate.com:3478,stun:stun.mixvoip.com:3478,stun:stun.nextcloud.com:3478,stun:stun.bethesda.net:3478,stun:stun.nextcloud.com:443 utls-imitate=hellorandomizedalpn
  • 保存 torrc 文件。

  • 从命令行运行 tor./tor -f torrc

  • Note: If you have installed little-t tor on Linux and modified the default torrc, you will have to restart the daemon.

故障排除

  • 如果 Tor 连接失败,请检查 torrc 文件的格式是否正确。
  • 如果通过 Tor 专家包安装了 tor,请确保 torrc 文件与 tor 二进制文件位于同一文件夹。
  • 检查 Tor 日志中的错误
  • After exhausting these common troubleshooting steps, if the connection still fails, the bridges you received may be offline or blocked. Obtain new set of bridges from the bridges website, via Email or via Telegram.