高度な使い方

タブを保存

OnionShareのタブを閉じると、タブは破棄され、これを再利用することはできません。固定タブでホストされているウェブサイトは、それをホストしているコンピューターが再起動した場合でも、同じアドレスでアクセスすることができます。

サーバーを開始する前に「OnionShare の起動時に常にこのタブを開く」にチェックを入れると、タブを固定することができます。

_images/advanced-save-tabs.png

OnionShareを開くと、前回のセッションで保存したタブを開きます。その後、それぞれのサービスを手動で開始すると、同じOnionShareのアドレスで、同一の秘密鍵で保護されたサービスが利用できるようになります。

タブを保存すると、そのOnion Serviceの秘密鍵のコピーがあなたのコンピューター上に保存されます。

秘密鍵を無効にする

既定では、全てのOnionShareのサービスは、秘密鍵で保護されます。これはTorでは「クライアント認証」と呼ばれているものです。

OnionShare のサービスを読み込むと、Tor Browser は秘密鍵を入力するよう要求します。サービスを公開したい場合は、秘密鍵を完全に無効にすることをお勧めします。

タブに関して秘密鍵を無効にするには、サーバーを開始する前に「公開のOnionShareのサービスとして設定(秘密鍵が無効となります)」にチェックを入れてください。そうすると、サーバーは公開され、Tor Browserでこれを読み込む際に秘密鍵を入力する必要はなくなります。

カスタムタイトル

Tor BrowserでOnionShareのサービスを読み込むと、それぞれの種類のサービスに既定のタイトルが表示されます。例えば、チャットのサービスの既定のタイトルは「OnionShare Chat」です。

サーバーを開始する前に「カスタムタイトル」を設定すると、既定のタイトルを変更できます。

スケジュールの設定

OnionShareでは、サービスを開始・停止する時刻を予定することができます。サーバーを開始する前に、そのタブの「詳細設定を表示」をクリックし、「指定の日時にOnion Serviceを開始」と「指定の日時にOnion Serviceを停止」の片方または両方にチェックを入れて、希望日時を入力してください。

今後開始する予定のサービスは、「共有を開始」ボタンをクリックするとカウントダウンタイマーが表示されます。今後停止する予定のサービスは、開始時にカウントダウンタイマーが表示されます。

OnionShareの自動開始の設定は「死者のスイッチ」として使用できます。その場合、もし将来、あなたによりOnionShareの自動開始の設定が解除されなければ、指定の日時にサービスが公開されます。何もあなたの身に起こらなければ、サービスが開始する前に、これを中止することができます。

_images/advanced-schedule-start-timer.png

OnionShareのサービスの自動終了の設定は、サービスが公開される期間を限定できます。古くなってしまう秘密の情報などを共有したい場合は、期間を選択、限定してこれを共有することができます。

_images/advanced-schedule-stop-timer.png

コマンドライン・インターフェース

グラフィカル・インターフェースに加えて、OnionShareにはコマンドライン・インターフェースがあります。

CLI バージョンのインストール

Snap、macOS、または Windows パッケージをインストールしている場合、CLI バージョンはすでにインストールされています。

あるいは、pip3 を使って OnionShare のコマンドライン版だけをインストールすることもできます。

pip3 install --user onionshare-cli

tor パッケージもインストールする必要があります。macOS の場合は brew install tor でインストールできます。

その後、次のコマンドを実行してください。

onionshare-cli --help

異なるOSでのインストールに関する情報については、GitレポジトリにあるコマンドラインREADMEファイルをご確認ください。

Snap からの CLI の実行

Snap パッケージを使用して OnionShare をインストールした場合は、 onionshare.cli を実行することで、コマンドラインインターフェイス版にアクセスできます。

macOS からの CLI の実行

ターミナルから /Applications/OnionShare.app/Contents/MacOS/onionshare-cli --help を実行します

Windows からの CLI の実行

Windows でのインストールでは、実行ファイル onionshare-cli.exe が利用できます。

使い方

コマンドラインのドキュメンテーションは onionshare --help で閲覧できます。

$ onionshare-cli --help
╭───────────────────────────────────────────╮
│    *            ▄▄█████▄▄            *    │
│               ▄████▀▀▀████▄     *         │
│              ▀▀█▀       ▀██▄              │
│      *      ▄█▄          ▀██▄             │
│           ▄█████▄         ███        -+-  │
│             ███         ▀█████▀           │
│             ▀██▄          ▀█▀             │
│         *    ▀██▄       ▄█▄▄     *        │
│ *             ▀████▄▄▄████▀               │
│                 ▀▀█████▀▀                 │
│             -+-                     *     │
│   ▄▀▄               ▄▀▀ █                 │
│   █ █     ▀         ▀▄  █                 │
│   █ █ █▀▄ █ ▄▀▄ █▀▄  ▀▄ █▀▄ ▄▀▄ █▄▀ ▄█▄   │
│   ▀▄▀ █ █ █ ▀▄▀ █ █ ▄▄▀ █ █ ▀▄█ █   ▀▄▄   │
│                                           │
│                  v2.4.1                   │
│                                           │
│          https://onionshare.org/          │
╰───────────────────────────────────────────╯

usage: onionshare-cli [-h] [--receive] [--website] [--chat] [--local-only] [--connect-timeout SECONDS] [--config FILENAME] [--persistent FILENAME] [--title TITLE] [--public]
                      [--auto-start-timer SECONDS] [--auto-stop-timer SECONDS] [--no-autostop-sharing] [--log-filenames] [--qr] [--data-dir data_dir] [--webhook-url webhook_url] [--disable-text]
                      [--disable-files] [--disable_csp] [--custom_csp custom_csp] [-v]
                      [filename ...]

positional arguments:
  filename                  List of files or folders to share

optional arguments:
  -h, --help                Show this help message and exit
  --receive                 Receive files
  --website                 Publish website
  --chat                    Start chat server
  --local-only              Don't use Tor (only for development)
  --connect-timeout SECONDS
                            Give up connecting to Tor after a given amount of seconds (default: 120)
  --config FILENAME         Filename of custom global settings
  --persistent FILENAME     Filename of persistent session
  --title TITLE             Set a title
  --public                  Don't use a private key
  --auto-start-timer SECONDS
                            Start onion service at scheduled time (N seconds from now)
  --auto-stop-timer SECONDS
                            Stop onion service at scheduled time (N seconds from now)
  --no-autostop-sharing     Share files: Continue sharing after files have been sent (the default is to stop sharing)
  --log-filenames           Log file download activity to stdout
  --qr                      Display a QR code in the terminal for share links
  --data-dir data_dir       Receive files: Save files received to this directory
  --webhook-url webhook_url
                            Receive files: URL to receive webhook notifications
  --disable-text            Receive files: Disable receiving text messages
  --disable-files           Receive files: Disable receiving files
  --disable_csp             Publish website: Disable the default Content Security Policy header (allows your website to use third-party resources)
  --custom_csp custom_csp   Publish website: Set a custom Content Security Policy header
  -v, --verbose             Log OnionShare errors to stdout, and web errors to disk

systemd ユニットファイルとしての CLI の実行

systemd ユニットファイルを使用して、CLI から OnionShare を自動的に起動できます。

「永続」モードで動作していて、マシンを起動するたびに同じ Onion Service を起動したい場合には特に便利です。

これを行うには、最初にいくつかの OnionShare json 構成を準備する必要があります。

これが OnionShare のメイン設定です。この例では、/home/user/.config/onionshare/onionshare.json に保存されています。いくつかの設定を調整する必要があるかもしれませんが、すでに OnionShare がインストールされている場合は、おそらく以下のようになります。

{
  "version": "2.6.2",
  "connection_type": "bundled",
  "control_port_address": "127.0.0.1",
  "control_port_port": 9051,
  "socks_address": "127.0.0.1",
  "socks_port": 9050,
  "socket_file_path": "/var/run/tor/control",
  "auth_type": "no_auth",
  "auth_password": "",
  "auto_connect": true,
  "use_autoupdate": true,
  "autoupdate_timestamp": null,
  "bridges_enabled": false,
  "bridges_type": "built-in",
  "bridges_builtin_pt": "obfs4",
  "bridges_moat": "",
  "bridges_custom": "",
  "bridges_builtin": {},
  "persistent_tabs": [
      "my-persistent-onion"
  ],
  "locale": "en",
  "theme": 0
}

「persistent_tabs」セクションに注目します。以下のようなファイルを /home/user/.config/onionshare/persistent/my-persistent-onion.json に作成します。

{
  "onion": {
      "private_key": "UDIaZD8QgoXRP8JnAJ+pnlogQazfZ0wrfWJk5zPBGUBqg6+lozzjUJKTYWxwrxR33pDgJdTFtCUN1CX1FE22UQ==",
      "client_auth_priv_key": "RHJSN4VI3NKGDSIWK45CCWTLYOJHA6DQQRQXUID3FXMAILYXWVUQ",
      "client_auth_pub_key": "J4YLYAHS25UU3TZTE27H32RN3MCRGLR345U52XS2JNQ76CCHCRSQ"
  },
  "persistent": {
      "mode": "share",
      "enabled": true
  },
  "general": {
      "title": null,
      "public": false,
      "autostart_timer": 0,
      "autostop_timer": 0,
      "service_id": "niktadkcp6z7rym3r5o3j2hnmis53mno5ughvur357xo7jkjvmqrchid",
      "qr": false
  },
  "share": {
     "autostop_sharing": true,
     "filenames": [
       "/home/user/my-shared-file.txt"
     ]
  },
  "receive": {
     "data_dir": "/home/user/OnionShare",
     "webhook_url": null,
     "disable_text": false,
     "disable_files": false
  },
  "website": {
     "disable_csp": false,
     "custom_csp": null,
     "filenames": []
  },
  "chat": {}
}

この秘密鍵、service_id、client_auth 鍵を実際に使用しないでください!これらはあくまで例です。秘密鍵は絶対に誰とも共有しないでください

Onion アドレスと秘密鍵を生成する最も簡単な方法は、まずデスクトップアプリで OnionShare タブを「ピン留め」して、初めて共有を開始することです。これにより、永続的な設定が .config/onionshare/persistent/ フォルダにランダムな名前で保存されます。最初に生成したタブは固定解除できます。あるいは、そのままにしておいて、以下の systemd ユニットファイルでその永続ファイルを使用することもできます。

これで、/etc/systemd/system/onionshare-cli.service に systemd ユニットファイルを作成できます。User と Group を自分のユーザー/グループに調整し、onionshare-cli バイナリへのパスや JSON 設定と共有へのパスも変更してください。

systemd ユニットファイルは以下のようになります。

[Unit]
Description=OnionShare CLI
After=network.target

[Service]
ExecStart=/home/user/.local/bin/onionshare-cli --persistent /home/user/.config/onionshare/persistent/my-persistent-onion.json /home/user/my-shared-file.txt
Restart=on-failure
User=user
Group=user

[Install]
WantedBy=multi-user.target

/home/user/my-shared-file.txtmy-persistent-onion.json ファイルの filenames セクションで定義されていますが、onionshare-cli コマンドの引数として指定する必要があります。

ユニットファイルを作成した後、必ず sudo systemctl daemon-reload を実行してください。

これで sudo systemctl start onionshare-cli.service を実行できます。journalctl がインストールされている場合は、sudo journalctl -f -t onionshare-cli を実行すると、以下のようにサービスの出力が表示されます。

[...]
Feb 09 10:14:09 onionshare onionshare-cli[18852]: [6.5K blob data]
Feb 09 10:14:18 onionshare onionshare-cli[18852]: Compressing files.
Feb 09 10:14:18 onionshare onionshare-cli[18852]: Give this address and private key to the recipient:
Feb 09 10:14:18 onionshare onionshare-cli[18852]: http://niktadkcp6z7rym3r5o3j2hnmis53mno5ughvur357xo7jkjvmqrchid.onion
Feb 09 10:14:18 onionshare onionshare-cli[18852]: Private key: RHJSN4VI3NKGDSIWK45CCWTLYOJHA6DQQRQXUID3FXMAILYXWVUQ
Feb 09 10:14:18 onionshare onionshare-cli[18852]: Press Ctrl+C to stop the server

ユーザーに秘密鍵を使わせたくない場合は、my-persistent-onion.json ファイルの general 設定で publictrue に設定します。

キーボードのショートカット

OnionShareのデスクトップアプリケーションには、利便性とアクセシビリティーの観点から、いくつかのキーボードショートカットがあります。

Ctrl T - New Tab
Ctrl X - Closes current tab

メインモードの選択画面については、以下のショートカットがあります。

Ctrl S - Share mode
Ctrl R - Receive mode
Ctrl W - Website mode
Ctrl C - Chat mode
Ctrl H - Settings tab

OnionShare データを別のコンピューターに移行する

別のコンピューターに乗り換えるときに、OnionShare のデータを移行したい場合もあるはずです。これは、「永続的な」Onion アドレスがあり、それを保持したい場合に特に当てはまるでしょう。

OnionShare は、このようなデータをすべて特定のフォルダーに保存します。次のオペレーティングシステムに対応するフォルダーを新しいコンピューターにコピーします。

  • Linux: ~/.config/onionshare

  • macOS: ~/Library/Application Support/OnionShare

  • Windows: %APPDATA%\OnionShare

設定ファイルのパラメーター

OnionShare stores its settings in a JSON file. Both the CLI and the Desktop versions use this configuration file. The CLI also lets you specify a path to a custom configuration file with --config.

Below are the configuration file parameters and what they mean. If your configuration file has other parameters not listed here, they may be obsolete from older OnionShare versions.

Parameter

Type

Explanation

バージョン

string

The version of OnionShare. You should not ever need to change this value.

connection_type

string

The way in which OnionShare connects to Tor. Valid options are 'bundled', 'automatic' (use Tor Browser's Tor connection), 'control_port' or 'socket_file'. Default: 'bundled'

control_port_address

string

The IP address of Tor's Control port, if connection_type is set to 'control_port'. Default: '127.0.0.1'

control_port_port

integer

The port number of Tor's Control port, if connection_type is set to 'control_port'. Default: '9051'

socks_address

string

The IP address of Tor's SOCKS proxy, if connection_type is set to 'control_port' or 'socket_file'. Default: '127.0.0.1'

socks_port

integer

The port number of Tor's SOCKS proxy, if connection_type is set to 'control_port' or 'socket_file'. Default: ''9050'

socket_file_path

string

The path to Tor's socket file, if connection_type is set to 'socket_file'. Default: '/var/run/tor/control'

auth_type

string

If access to Tor's control port requires a password, this can be set to 'password', otherwise 'no_auth'. Default: 'no_auth'

auth_password

string

If access to Tor's control port requires a password, and auth_type is set to 'password', specify the password here. Default: ''

auto_connect

boolean

Whether OnionShare should automatically connect to Tor when it starts. Default: False

use_autoupdate

boolean

Whether OnionShare should automatically check for updates (over Tor). This setting is only valid for MacOS or Windows installations. Default: True.

autoupdate_timestamp

integer

The last time OnionShare checked for updates. Default: None

bridges_enabled

boolean

Whether to connect to Tor using bridges. Default: False

bridges_type

string

When bridges_enabled is True, where to load bridges from. Options are "built-in" (bridges shipped with OnionShare and which may get updated from Tor), "moat" (request bridges from Tor's Moat API), or "custom" (user-supplied bridges). Default: "built-in"

bridges_builtin_pt

string

When bridges_type is set to "built-in", this specifies which type of bridge protocol to use. Options are "obfs4", "meek-azure" or "snowflake". Default: "obfs4"

bridges_moat

string

When bridges_type is set to "moat", the bridges returned from Tor's Moat API are stored here. Default: ""

bridges_custom

string

When bridges_type is set to "custom", the bridges specified by the user are stored here. Separate each bridge line in the string with 'n'. Default: ""

bridges_builtin

dict

When bridges_type is set to "built-in", OnionShare obtains the latest built-in bridges recommended by Tor and stores them here. Default: {}

persistent_tabs

list

If the user has defined any tabs as 'saved' (meaning that they are persistent each time OnionShare starts, and their onion address doesn't change), these are given a random identifier which gets listed here. The persistent onion is stored as a JSON file with the same name as this identifier, in a subfolder of the OnionShare configuration folder called 'persistent'. Default: []

locale

string

The locale used in OnionShare. Default: None (which is the same as 'en'). For valid locale codes, see 'available_locales' in https://github.com/onionshare/onionshare/blob/main/cli/onionshare_cli/settings.py

theme

boolean

The theme for the OnionShare desktop app. Valid options are 0 (automatically detect the user's computer's light or dark theme), 1 (light) or 2 (dark).

Configuration file parameters for persistent onions

As described above, each 'persistent' onion has parameters of its own which are stored in its own JSON file. The path to this file can be specified for the CLI tool with --persistent.

Here is an example persistent JSON configuration:

{
  "onion": {
      "private_key": "0HGxILDDwYhxAB2Zq8mM3Wu3MirBgK7Fw2/tVrTw1XraElH7MWbVn3lzKbcJEapVWz2TFjaoCAVN48hGqraiRg==",
      "client_auth_priv_key": "UT55HDBA5VSRWOUERMGOHEIBKZCMOOGZAFFNI54GDQFZ6CMCUGIQ",
      "client_auth_pub_key": "TPQCMCV26UEDMCWGZCWAWM4FOJSQKZZTVPC5TC3CAGMDWKV255OA"
  },
  "persistent": {
      "mode": "share",
      "enabled": true,
      "autostart_on_launch": false
  },
  "general": {
      "title": null,
      "public": false,
      "autostart_timer": false,
      "autostop_timer": false,
      "service_id": "hvsufvk2anyadehahfqiacy4wbrjt2atpnagk4itlkh4mdfsg6vhd5ad"
  },
  "share": {
      "autostop_sharing": true,
      "filenames": [
          "/home/user/git/onionshare/desktop/org.onionshare.OnionShare.svg"
      ],
      "log_filenames": false
  },
  "receive": {
      "data_dir": "/home/user/OnionShare",
      "webhook_url": null,
      "disable_text": false,
      "disable_files": false
  },
  "website": {
      "disable_csp": false,
      "custom_csp": null,
      "log_filenames": false,
      "filenames": []
  },
  "chat": {}
}

Below are the configuration file parameters for a persistent onion and what they mean, for each section in the JSON

onion

Parameter

Type

Explanation

private_key

string

Base64-encoded private key of the onion service

client_auth_priv_key

string

The private key when using Client Authentication. Send this to the user.

client_auth_pub_key

string

The public key when using Client Authentication. Used on OnionShare's side.

永続

Parameter

Type

Explanation

mode

string

The mode used by this persistent onion. Options are "share", "receive", "website" or "chat".

enabled

boolean

Whether persistence is enabled for this onion. When the persistent option is unchecked in the desktop, this entire JSON file is deleted. Default: true

autostart_on_launch

boolean

Whether to automatically start this persistent onion when OnionShare starts and once Tor is connected. Default: false

general

Parameter

Type

Explanation

title

string

An optional custom title for displaying on the onion service. Default: null ("OnionShare" will be shown instead)

公開

boolean

Whether the onion service can be accessed with or without a Private Key (Client Authentication). If true, no Private Key is required.

autostart_timer

boolean

Whether the onion service is configured to start at a specific time. The time can be set in the desktop app or specified in seconds with --auto-start-timer with the CLI tool. Default: false

autostop_timer

boolean

Whether the onion service is configured to stop at a specific time. The time can be set in the desktop app or specified in seconds with --auto-stop-timer with the CLI tool. Default: false

service_id

string

The 32-character onion service URL, without the scheme and without the '.onion' suffix.

The below are settings specific to the 'mode' specified in the persistent section above.

共有

Parameter

Type

Explanation

autostop_sharing

boolean

Whether to automatically stop the share once files are downloaded the first time. Default: true

filenames

list

A list of files to share. Default: []

log_filenames

boolean

Whether to log URL requests to stdout when using the CLI tool. Default: false

receive

Parameter

Type

Explanation

data_dir

string

The path where received files or text messages will be stored. Default: the 'OnionShare' folder of the user's home directory.

webhook_url

string

A webhook URL that OnionShare will POST to when it receives files or text messages. Default: null

disable_text

boolean

Whether to disable receiving text messages. Default: false

disable_files

boolean

Whether to disable receiving files. Default: false

website

Parameter

Type

Explanation

disable_csp

boolean

If set to true, OnionShare won't set its default Content Security Policy header for the website. Default: false

custom_csp

string

A custom Content Security Policy header to send instead of the default.

log_filenames

boolean

Whether to log URL requests to stdout when using the CLI tool. Default: false

filenames

list

A list of files to share. Default: []

チャット

There are currently no configurable settings for the Chat mode.