Tor 指令備忘

以前一直以為 Tor 一定要配合引導,後來看到文章才知道 Tor 可以在指令模式下運作,真該早點看官方文件的…記錄一下常用的指令

安裝服務
tor –service install

服務執行
tor –service start

指定設定檔
tor -f

開啟用批次檔(要用系統管理員權系),另存成 .bat

1
2
3
4
5
6
@echo off
set Path=TOR.exe所在的路徑
::set Path=%~dp0
echo %Path%
%Path%\Tor\tor.exe --service start --defaults-torrc %Path%\Data\Tor\torrc-defaults -f %Path%\Data\Tor\torrc
pause

資料來源1,先簡易用 Google 翻譯,有機會再調整。

COMMAND-LINE OPTIONS

-h, -help
    Display a short help message and exit.
    幫助,可查看可用指令

-f FILE
    Specify a new configuration file to contain further Tor configuration options OR pass - to make Tor read its configuration from standard input. (Default: @CONFDIR@/torrc, or $HOME/.torrc if that file is not found)
    指定設定檔,預設會找尋 @CONFDIR@/torrc, or $HOME/.torrc

--allow-missing-torrc
    Do not require that configuration file specified by -f exist if default torrc can be accessed.
    如果存在預設設定檔,就忽略 -f 參數

--defaults-torrc FILE
    Specify a file in which to find default values for Tor options. The contents of this file are overridden by those in the regular configuration file, and by those on the command line. (Default: @CONFDIR@/torrc-defaults.)
    指定一個檔案,在其中查找 Tor 選項的預設值。該檔案的內容會被常規設定檔中的內容以及命令行中的內容覆蓋。 (預設:@ CONFDIR @ / torrc-defaults。)

--ignore-missing-torrc
    Specifies that Tor should treat a missing torrc file as though it were empty. Ordinarily, Tor does this for missing default torrc files, but not for those specified on the command line.
    指定 Tor 應該將丟失的 torrc 文件視為空文件。通常,Tor 會為缺少的預設 torrc 文件執行此操作,但不會在命令行中指定。

--hash-password PASSWORD
    Generates a hashed password for control port access.
    為控制端口訪問生成散列密碼。

--list-fingerprint
    Generate your keys and output your nickname and fingerprint.
    生成您的密鑰並輸出您的暱稱和指紋。

--verify-config
    Verify the configuration file is valid.
    驗證設定檔是否有效。

--service install [--options command-line options]
    Install an instance of Tor as a Windows service, with the provided command-line options. Current instructions can be found at https://www.torproject.org/docs/faq#NTService
    使用提供的命令行選項,將 Tor 的實例安裝為 Windows 服務。

--service remove|start|stop
    Remove, start, or stop a configured Tor Windows service.
    刪除,啟動或停止配置的 Tor Windows 服務。

--nt-service
    Used internally to implement a Windows service.
    在內部用於實現 Windows 服務。

--list-torrc-options
    List all valid options.
    列出所有有效的選項。

--list-deprecated-options
    List all valid options that are scheduled to become obsolete in a future version. (This is a warning, not a promise.)
    列出將來版本中計劃廢棄的所有有效選項。 (這是提前警告,不是保證。)

--version
    Display Tor version and exit.
    顯示 Tor 版本並退出。

--quiet|--hush
    Override the default console log. By default, Tor starts out logging messages at level "notice" and higher to the console. It stops doing so after it parses its configuration, if the configuration tells it to log anywhere else. You can override this behavior with the --hush option, which tells Tor to only send warnings and errors to the console, or with the --quietoption, which tells Tor not to log to the console at all.
    覆蓋預設控制台日誌。預設情況下,Tor 在 “通知” 級別開始記錄消息並將其發送到控制台。它在解析其配置後會停止,如果配置告訴它在其他地方記錄。您可以使用 --hush 選項覆蓋此行為,該選項告訴 Tor 僅向控制台發送警告和錯誤,或者使用 --quiet 選項,它告訴 Tor 根本不登錄控制台。

--keygen [--newpass]
    Running "tor --keygen" creates a new ed25519 master identity key for a relay, or only a fresh temporary signing key and certificate, if you already have a master key. Optionally you can encrypt the master identity key with a passphrase: Tor will ask you for one. If you don't want to encrypt the master key, just don't enter any passphrase when asked.

    The --newpass option should be used with --keygen only when you need to add, change, or remove a passphrase on an existing ed25519 master identity key. You will be prompted for the old passphase (if any), and the new passphrase (if any).

    When generating a master key, you will probably want to use --DataDirectory to control where the keys and certificates will be stored, and --SigningKeyLifetime to control their lifetimes. Their behavior is as documented in the server options section below. (You must have write access to the specified DataDirectory.)

    To use the generated files, you must copy them to the DataDirectory/keys directory of your Tor daemon, and make sure that they are owned by the user actually running the Tor daemon on your system.
    運行 “tor -keygen” 將為中繼創建一個新的 ed25519 主身份密鑰,或者只有新的臨時簽名密鑰和證書(如果您已有主密鑰)。或者,您可以使用密碼加密主身份識別碼:Tor 會要求您輸入密碼。如果您不想加密主密鑰,請在輸入密碼時不要輸入密碼。

    只有在需要添加,更改或刪除現有 ed25519 主身份密鑰上的密碼時, - newpass 選項才應與 --keygen 一起使用。系統會提示您輸入舊的 passphase(如果有)和新的密碼(如果有的話)。

    在生成主密鑰時,您可能需要使用 --DataDirectory 來控制密鑰和證書的存儲位置,以及 --SigningKeyLifetime 來控制它們的生命週期。它們的行為如下面的服務器選項部分所述。 (您必須具有對指定 DataDirectory 的寫入權限。)

    要使用生成的文件,必須將它們複製到 Tor 守護程序的 DataDirectory/keys 目錄中,並確保它們由實際在系統上運行 Tor 守護程序的用戶擁有。

--passphrase-fd FILEDES
    Filedescriptor to read the passphrase from. Note that unlike with the tor-gencert program, the entire file contents are read and used as the passphrase, including any trailing newlines. Default: read from the terminal.
    Filedescriptor 從中讀取密碼。請注意,與 tor-gencert 程序不同,整個文件內容都被讀取並用作密碼,包括任何尾隨的換行符。預設:從終端讀取。

--key-expiration [purpose]
    The purpose specifies which type of key certificate to determine the expiration of. The only currently recognised purpose is "sign".
    目的是指定哪種類型的密鑰證書來確定過期。目前唯一認可的目的是 “符號”。

    Running "tor --key-expiration sign" will attempt to find your signing key certificate and will output, both in the logs as well as to stdout, the signing key certificates expiration time in ISO-8601 format. For example, the output sent to stdout will be of the form: "signing-cert-expiry: 2017-07-25 08:30:15 UTC"
    運行 “tor -key-expiration sign” 將嘗試查找您的簽名密鑰證書,並且將在日誌以及 stdout 中輸出 ISO-8601 格式的簽名密鑰證書過期時間。例如,發送到 stdout 的輸出將採用以下格式:“signing-cert-expiry:2017-07-25 08:30:15 UTC”

Other options can be specified on the command-line in the format “–option value”, in the format”option value”, or in a configuration file. For instance, you can tell Tor to start listening for SOCKS connections on port 9999 by passing –SocksPort 9999 or SocksPort 9999 to it on the command line, or by putting “SocksPort 9999” in the configuration file. You will need to quote options with spaces in them: if you want Tor to log all debugging messages to debug.log, you will probably need to say –Log debug file debug.log.
其他選項可以在命令行中以 “- 選項值” 格式,“選項值” 格式或在設定檔中指定。例如,您可以通過在命令行上傳遞 –SocksPort9999 或 SocksPort 9999,或通過在設定檔中放入 “SocksPort 9999” 來指示 Tor 開始監聽端口 9999 上的 SOCKS 連接。你需引用帶有空格的選項:如果你想 Tor 把所有的調試信息記錄到 debug.log,你可能需要說 –Log 調試文件 debug.log。

如何在每次 Windows 登入時自動啟動需要以系統管理員身份執行的程式

------ THE END ------