Little-t-tor

警告: 這些說明適用於安裝tor網路守護程式,即little-t-tor. 有關安裝Tor 瀏覽器橋接中繼站的資訊,請參考洋蔥路由瀏覽器使用手冊

需要管理員權限:要安裝 Tor,您需要 root 權限。 Below all commands that need to be run as root user like apt and dpkg are prepended with '#', while commands to be run as user with '$' resembling the standard prompt in a terminal. To open a root terminal you have several options: sudo su, or sudo -i, or su -i. Note that sudo asks for your user password, while su expects the root password of your system.

Debian / Ubuntu

千萬別使用Ubuntu官方universe套件庫裡的版本。 In the past they have not reliably been updated. That means you could be missing stability and security fixes.

  1. Configure Tor package repository

Enable the Tor Project APT repository by following the instructions.

  1. 套件安裝

    # apt install tor

Fedora

  1. Configure Tor Package repository

Enable the Tor Project's RPM package repository by following the instructions.

  1. 套件安裝

    # dnf install tor

FreeBSD

  1. 套件安裝

    # pkg install tor

OpenBSD

  1. 套件安裝

    # pkg_add tor

macOS

  1. 安裝一個套件管理器

OS X 有二種套件管理器: Homebrew 與 Macports。 You can use the package manager of your choice.

安裝 Homebrew 請依 brew.sh 指示。

安裝 Macports 請照 macports.org/install.php 指示。

  1. 套件安裝

If you are using Homebrew in a Terminal window, run:

# brew install tor

If you are using Macports in a Terminal window, run:

$ sudo port install tor

Arch Linux

  1. 在Arch Linux上安裝tor套件,執行:
# pacman -Syu tor

DragonFlyBSD

  1. Bootstrap pkg

DragonFlyBSD's daily snapshots and releases (starting with 3.4) come with pkg already installed. Upgrades from earlier releases, however, will not have it. If pkg is missing on the system for any reason, it can be quickly bootstrapped without having to build it from source or even having DPorts installed:

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

1.1 設定 pkg 的推薦步驟

Here, it will be similar to what we have on a FreeBSD system, and we are going to use HTTPS to fetch our packages, and updates - so here we also need an extra package to help us out (ca_root_nss).

正在安裝ca_root_nss組件:

# pkg install ca_root_nss

For fresh installations, the file /usr/local/etc/pkg/repos/df-latest.conf.sample is copied to /usr/local/etc/pkg/repos/df-latest. The files ending in the ".sample" extension are ignored; pkg(8) only reads files that end in ".conf" and it will read as many as it finds.

DragonflyBSD 有兩個套件儲存庫:

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

We can simply edit the URL used to point out the repositories on /usr/local/etc/pkg/repos/df-latest and that's it! Remember to use pkg+https:// for Avalon.

在確認這些所有的變更後,我們再次更新軟體包列表,並嘗試檢查是否已經有新的更新要套用:

# pkg update -f
# pkg upgrade -y -f
  1. 套件安裝

安裝tor組件:

# pkg install tor

NetBSD

  1. 設定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
  1. 套件安裝

安裝torNetBSD的組件:

# pkg_add tor

Void Linux

To install the tor package on Void Linux, please run:

# xbps-install -S tor

正在從來源安裝Tor

  1. Download latest release and dependencies

最新的 Tor 發行版本可以在 下載頁面找到。

If you're building from source, first install libevent, and make sure you have openssl and zlib (including the -devel packages if applicable).

  1. 安裝Tor

    tar -xzf tor-0.4.3.6.tar.gz; cd tor-0.4.3.6

    ./configure && make

現在你可以執行tor作為 src/app/tor(0.4.3.x 或更新),或者你也可以執行make install(如有必要,請用 root 身分) 來將其安裝在/usr/local/,然後你就可以透過執行 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程式了,這是在大多數GNU/Linux系統的封裝發行版中會預載的軟體。

若要驗證其數位簽章,您需要在命令列模式輸入幾道指令。 這個方式會隨著您所使用的系統發行版不同而有所差異。

取得洋蔥路由開發人員的金鑰

下面的密鑰可以對 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 進行驗證。

底下範例假設您將該二檔案存放於「下載」資料夾中。 請注意,此處的指令中都是使用範例檔名,跟您所實際下載取得的檔名不會相同:您下載的可能不是第9.0版,而且也可能不是英文(美式)版本。

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