
高速なTCP/UDPトンネルをHTTP上で提供し、SSH暗号化をサポート。リバースポート転送、SOCKS5プロキシ、クライアント認証により、安全なネットワーク経路確保とファイアウォール回避を実現します。
Chiselは、HTTP上で転送され、SSHで保護される高速なTCP/UDPトンネルです。クライアントとサーバーの両方を含む単一の実行ファイルです。Go(golang)で書かれています。Chiselは主にファイアウォールを通過するのに役立ちますが、ネットワークへの安全なエンドポイントを提供するためにも使用できます。

--min/max-retry-intervalssh -o ProxyCommandをサポートするstdio上のクライアント接続。HTTP上でSSHを提供します最新リリースを参照するか、curl https://i.jpillora.com/chisel! | bashで今すぐダウンロードしてインストールしてください。
バイナリは最新のGoリリースでビルドされており、最小OSバージョンは次のとおりです: Windows 10 / Server 2016、macOS 12、Linuxカーネル3.2、FreeBSD 12.2。古いシステム(例: Windows 7)の場合は、リリースv1.8.1以前を使用してください。
イメージはマルチアーキテクチャ対応で、Docker Hub(`jpillora/chisel`)とGitHub Container Registry(`ghcr.io/jpillora/chisel`)の両方に公開されています。
### Fedora
このパッケージはFedoraコミュニティによってメンテナンスされています。RPMの使用に関連する問題が発生した場合は、この[issueトラッカー](https://bugzilla.redhat.com/buglist.cgi?bug_status=NEW&bug_status=ASSIGNED&classification=Fedora&component=chisel&list_id=11614537&product=Fedora&product=Fedora%20EPEL)を使用してください。```sh
sudo dnf -y install chisel
$ go install github.com/jpillora/chisel@latest
## デモ
数分で独自のデモサーバーを実行できます(旧HerokuデモはHerokuの無料枠の廃止に伴い終了しました)。[`example/fly.toml`](https://github.com/jpillora/chisel/blob/HEAD/example/fly.toml) は、この `chisel server` を [fly.io](https://fly.io) の無料枠にデプロイします:```sh
$ chisel server --port $PORT --backend http://example.com
# listens on $PORT, proxies normal web requests to http://example.com
Deploy it with fly launch --copy-config from the example/ directory, then tunnel to any service running beside the server, e.g.:```sh
$ chisel client https://.fly.dev 3000
ブラウザでアプリのURLにアクセスすると、サーバーのデフォルトのバックエンドプロキシに到達し、[example.com](http://example.com) のコピーが表示されます。
## 使用方法
<!-- これらのヘルプテキストは手動でレンダリングするか、
https://github.com/jpillora/md-tmpl を使用してください
$ md-tmpl -w README.md で実行します -->
<!--tmpl,code=plain:echo "$ chisel --help" && go run main.go --help | sed 's#0.0.0-src (go1\..*)#X.Y.Z#' -->``` plain
$ chisel --help
Usage: chisel [command] [--help]
Version: X.Y.Z
Commands:
server - runs chisel in server mode
client - runs chisel in client mode
Read more:
https://github.com/jpillora/chisel
$ chisel server --help
Usage: chisel server [options]
Options:
--host, Defines the HTTP listening host – the network interface
(defaults the environment variable HOST and falls back to 0.0.0.0).
--port, -p, Defines the HTTP listening port (defaults to the environment
variable PORT and falls back to port 8080).
--key, (deprecated use --keygen and --keyfile instead)
An optional string to seed the generation of a ECDSA public
and private key pair. All communications will be secured using this
key pair. Share the subsequent fingerprint with clients to enable detection
of man-in-the-middle attacks (defaults to the CHISEL_KEY environment
variable, otherwise a new key is generate each run).
--keygen, A path to write a newly generated PEM-encoded SSH private key file.
If users depend on your --key fingerprint, you may also include your --key to
output your existing key. Use - (dash) to output the generated key to stdout.
--keyfile, An optional path to a PEM-encoded SSH private key. When
this flag is set, the --key option is ignored, and the provided private key
is used to secure all communications. (defaults to the CHISEL_KEY_FILE
environment variable). Since ECDSA keys are short, you may also set keyfile
to the inline key string itself, exactly as printed by --keygen (a base64
string with a "ck-" prefix); no extra base64 encoding is needed.
--authfile, An optional path to a users.json file. This file should
be an object with users defined like:
{
"<user:pass>": ["<addr-regex>","<addr-regex>"]
}
when <user> connects, their <pass> will be verified and then
each of the remote addresses will be compared against the list
of address regular expressions for a match. Patterns are NOT
anchored by default: "10.0.0.1:80" also matches
"210.0.0.1:8080", and "." matches any character. Anchor your
patterns, e.g. "^10\.0\.0\.1:80$". The empty string ""
matches every address. Addresses will
always come in the form "<remote-host>:<remote-port>" for normal remotes,
"R:<local-interface>:<local-port>" for reverse port forwarding
remotes, and "socks" for SOCKS5 proxy access. Note that SOCKS5
access previously bypassed this list; existing authfiles which
should allow SOCKS5 must add an entry matching "socks" (the
empty wildcard "" matches everything, including "socks"). This
file will be automatically reloaded on change. Reloads apply
to new connections and to new tunnels of connected clients;
established tunnels are not interrupted.
--auth, An optional string representing a single user with full
access, in the form of <user:pass>. It is equivalent to creating an
authfile with {"<user:pass>": [""]}. If unset, it will use the
environment variable AUTH.
--keepalive, An optional keepalive interval. Since the underlying
transport is HTTP, in many instances we'll be traversing through
proxies, often these proxies will close idle connections. You must
specify a time with a unit, for example '5s' or '2m'. Defaults
to '25s' (set to 0s to disable).
--backend, Specifies another HTTP server to proxy requests to when
chisel receives a normal HTTP request. Useful for hiding chisel in
plain sight. --proxy is accepted as an alias for this flag.
--socks5, Allow clients to access the internal SOCKS5 proxy. See
chisel client --help for more information.
--reverse, Allow clients to specify reverse port forwarding remotes
in addition to normal remotes.
--tls-key, Enables TLS and provides optional path to a PEM-encoded
TLS private key. When this flag is set, you must also set --tls-cert,
and you cannot set --tls-domain.
--tls-cert, Enables TLS and provides optional path to a PEM-encoded
TLS certificate. When this flag is set, you must also set --tls-key,
and you cannot set --tls-domain.
--tls-domain, Enables TLS and automatically acquires a TLS key and
certificate using LetsEncrypt. Setting --tls-domain requires port 443.
You may specify multiple --tls-domain flags to serve multiple domains.
The resulting files are cached in the "$HOME/.cache/chisel" directory.
You can modify this path by setting the CHISEL_LE_CACHE variable,
or disable caching by setting this variable to "-". You can optionally
provide a certificate notification email by setting CHISEL_LE_EMAIL.
--tls-ca, a path to a PEM encoded CA certificate bundle or a directory
holding multiple PEM encode CA certificate bundle files, which is used to
validate client connections. The provided CA certificates will be used
instead of the system roots. This is commonly used to implement mutual-TLS.
--pid Generate pid file in current working directory
-v, Enable verbose logging
--help, This help text
Signals: The chisel process is listening for: a SIGINT or SIGTERM to begin a graceful shutdown (a second signal forces an immediate exit), a SIGUSR2 to print process stats, and a SIGHUP to short-circuit the client reconnect timer
Version: X.Y.Z
Read more: https://github.com/jpillora/chisel
<!--/tmpl-->
<!--tmpl,code=plain:echo "$ chisel client --help" && go run main.go client --help | sed 's#0.0.0-src (go1\..*)#X.Y.Z#' -->``` plain
$ chisel client --help
Usage: chisel client [options] <server> <remote> [remote] [remote] ...
<server> is the URL to the chisel server.
<remote>s are remote connections tunneled through the server, each of
which come in the form:
<local-host>:<local-port>:<remote-host>:<remote-port>/<protocol>
■ local-host defaults to 0.0.0.0 (all interfaces).
■ local-port defaults to remote-port.
■ remote-port is required*.
■ remote-host defaults to 127.0.0.1 (server localhost).
■ protocol defaults to tcp.
which shares <remote-host>:<remote-port> from the server to the client
as <local-host>:<local-port>, or:
R:<local-interface>:<local-port>:<remote-host>:<remote-port>/<protocol>
which does reverse port forwarding, sharing <remote-host>:<remote-port>
from the client to the server's <local-interface>:<local-port>.
example remotes
3000
example.com:3000
3000:google.com:80
192.168.0.5:3000:google.com:80
socks
5000:socks
R:2222:localhost:22
R:socks
R:5000:socks
stdio:example.com:22
1.1.1.1:53/udp
When the chisel server has --socks5 enabled, remotes can
specify "socks" in place of remote-host and remote-port.
The default local host and port for a "socks" remote is
127.0.0.1:1080. Connections to this remote will terminate
at the server's internal SOCKS5 proxy. When the server also
has --authfile set, SOCKS5 access requires an entry matching
the token "socks" in the user's address list.
When the chisel server has --reverse enabled, remotes can
be prefixed with R to denote that they are reversed. That
is, the server will listen and accept connections, and they
will be proxied through the client which specified the remote.
Reverse remotes specifying "R:socks" will listen on the server's
default socks port (1080) and terminate the connection at the
client's internal SOCKS5 proxy.
When stdio is used as local-host, the tunnel will connect standard
input/output of this program with the remote. This is useful when
combined with ssh ProxyCommand. You can use
ssh -o ProxyCommand='chisel client chiselserver stdio:%h:%p' \
[email protected]
to connect to an SSH server through the tunnel.
Options:
--fingerprint, A *strongly recommended* fingerprint string
to perform host-key validation against the server's public key.
Fingerprint mismatches will close the connection.
Fingerprints are generated by hashing the ECDSA public key using
SHA256 and encoding the result in base64.
Fingerprints must be 44 characters containing a trailing equals (=).
Legacy MD5 colon fingerprints (deprecated) are still accepted,
but only in their full 16-octet form; truncated prefixes are
rejected.
--auth, An optional username and password (client authentication)
in the form: "<user>:<pass>". These credentials are compared to
the credentials inside the server's --authfile. defaults to the
AUTH environment variable.
--keepalive, An optional keepalive interval. Since the underlying
transport is HTTP, in many instances we'll be traversing through
proxies, often these proxies will close idle connections. You must
specify a time with a unit, for example '5s' or '2m'. Defaults
to '25s' (set to 0s to disable).
--max-retry-count, Maximum number of times to retry before exiting.
Defaults to unlimited.
--min-retry-interval, Minimum wait time before retrying after a
disconnection. Defaults to 1 second.
--max-retry-interval, Maximum wait time before retrying after a
disconnection. Defaults to 5 minutes.
--proxy, An optional HTTP CONNECT or SOCKS5 proxy which will be
used to reach the chisel server. Authentication can be specified
inside the URL. Credentials must be URL-encoded; for example a
"#" in the password must be written as "%23".
For example, http://admin:[email protected]:8081
or: socks://admin:[email protected]:1080
The socks://, socks5:// and socks5h:// schemes are equivalent:
DNS is always resolved by the proxy.
--header, Set a custom header in the form "HeaderName: HeaderContent".
Can be used multiple times. (e.g --header "Foo: Bar" --header "Hello: World")
--hostname, Optionally set the 'Host' header (defaults to the host
found in the server url).
--sni, Override the ServerName when using TLS (defaults to the
hostname).
--tls-ca, An optional root certificate bundle used to verify the
chisel server. Only valid when connecting to the server with
"https" or "wss". By default, the operating system CAs will be used.
--tls-skip-verify, Skip server TLS certificate verification of
chain and host name (if TLS is used for transport connections to
server). If set, client accepts any TLS certificate presented by
the server and any host name in that certificate. This only affects
transport https (wss) connection. Chisel server's public key
may be still verified (see --fingerprint) after inner connection
is established.
--tls-key, a path to a PEM encoded private key used for client
authentication (mutual-TLS).
--tls-cert, a path to a PEM encoded certificate matching the provided
private key. The certificate must have client authentication
enabled (mutual-TLS).
--pid Generate pid file in current working directory
-v, Enable verbose logging
--help, This help text
Signals:
The chisel process is listening for:
a SIGINT or SIGTERM to begin a graceful shutdown
(a second signal forces an immediate exit),
a SIGUSR2 to print process stats, and
a SIGHUP to short-circuit the client reconnect timer
Version:
X.Y.Z
Read more:
https://github.com/jpillora/chisel
暗号化は常に有効です。chiselサーバーを起動すると、インメモリのECDSA公開鍵/秘密鍵ペアが生成されます。公開鍵のフィンガープリント(base64エンコードされたSHA256)は、サーバーの起動時に表示されます。ランダムな鍵を生成する代わりに、サーバーは--keyfileオプションを使用して鍵ファイルを指定することもできます。クライアントが接続すると、サーバーの公開鍵フィンガープリントも表示されます。クライアントは--fingerprintオプションを使用して特定のフィンガープリントを強制できます。レガシーなMD5フィンガープリントも引き続き受け入れられますが、完全な16オクテットのコロン区切り形式である必要があります。切り詰められたプレフィックスは拒否されます。詳細については、上記の--helpを参照してください。
サーバーはまた、認証前のインバウンドWebSocketメッセージサイズを制限します(CHISEL_WS_READ_LIMIT、デフォルトは512 KiB)。これにより、認証されていないピアが過大なメッセージでメモリを枯渇させることができなくなります。デフォルトはx/crypto/sshの256 KiBの最大トランスポートパケットを十分に上回るため、有効なSSHパケットが拒否されることはありません。制限を無効にするのは0のみです。負の値は安全なデフォルトにフォールバックします。
--authfileオプションを使用すると、サーバーはuser.json設定ファイルを提供して、受け入れられるユーザーのリストを作成できます。クライアントは--authオプションを使用して認証します。認証設定ファイルの例については、users.jsonを参照してください。詳細については、上記の--helpを参照してください。
authfileの動作に関する注意事項:
^と$でアンカーしてください(サーバーは読み込み時にアンカーされていないパターンについて警告します)。空文字列""はすべてに一致します。socksに一致するエントリによって制御されます。破壊的変更:SOCKS5は以前はauthfileを完全にバイパスしていました。--authfileとともに--socks5を実行しているサーバーは、プロキシアクセスを維持すべきユーザーにsocksを付与する必要があります(ワイルドカード""エントリは引き続き機能します)。user:pass)を含まない認証文字列は、サーバーとクライアントの両方で致命的な起動エラーになりました。以前は認証を静かに無効化していました。--authユーザーはauthfileの再読み込み後も存続し、ファイル内のユーザーとの名前の競合に勝ちます。内部的には、これはSSHが提供する_Password_認証方式を使用して行われます。crypto/sshの詳細については、http://blog.gopheracademy.com/go-and-ssh/ を参照してください。セッションのオープン/クローズ(ユーザー、送信元アドレス、リモート付き)と失敗したログイン試行は、infoレベルでログに記録されます。
最もシンプルな安全な設定は--tls-domainです。これによりLetsEncrypt証明書が自動的にプロビジョニングされます(ポート443と、サーバーを指すDNSレコードが必要です):```sh
chisel server --port 443 --tls-domain chisel.example.com --auth user:pass
chisel client --auth user:pass https://chisel.example.com R:2222:localhost:22
独自の証明書(自己署名または内部CA)を使用するには、キー/証明書のペアを生成し、両側で適切なファイルを指定します。```sh
chisel server --port 443 --tls-key key.pem --tls-cert cert.pem
chisel client --tls-ca ca.pem https://chisel.example.com 3000
相互TLSの場合は、サーバー側にも--tls-caを、各クライアント側にも--tls-cert/--tls-keyを渡します。TLSはchiselのトランスポートを外側からラップすることに注意してください。内側のSSH層は依然として暗号化と認証を行うため、--fingerprint検証はTLSの有無にかかわらず機能します。
新しい秘密鍵をターミナルに出力します
chisel server --keygen -
# またはディスクに保存 --keygen /path/to/mykey
chiselサーバーを起動します
jpillora/chisel server --keyfile '<ck-base64文字列またはファイルパス>' -p 9312 --socks5
chiselクライアントを接続します(サーバーのフィンガープリントを使用)
chisel client --fingerprint '<サーバー出力を確認>' <server-address>:9312 socks
SOCKS5クライアント(例: OS/ブラウザ)を次の場所に向けます:
<client-address>:1080
これで、HTTP上で暗号化・認証されたSOCKS5接続が確立されます
注: サーバーが--authfileも使用している場合、ユーザーはプロキシを使用するためにトークンsocksに一致するエントリが必要です(認証を参照)。
特定のクライアントをSOCKS出口ノードとして動作させるには、そのクライアントにリバースSOCKSリスナーアドレス(R:socksはサーバーの127.0.0.1:1080で待ち受けます)を付与します:```json
{
"exituser:password": ["^R:127\.0\.0\.1:1080$"]
}
I need the actual content of chunk 23 to translate it. Please provide the Markdown text you'd like me to translate from English to Japanese.```sh
chisel server --reverse --authfile users.json
chisel client --auth exituser:password <server-address> R:socks
# server-side consumers point SOCKS5 clients at 127.0.0.1:1080,
# and their traffic exits via the chisel client's network
また、ステップバイステップのリバーストンネリングの例も参照してください。
chiselはWebSocketsをサポートするCDNを通じて動作します。Cloudflareの場合:WebSocketsを有効にし、DNSレコードをプロキシ(オレンジクラウド)し、クライアントをhttps://で接続します。CDNがTLSを終端しますが、内部のSSHレイヤーにより、--fingerprint検証は依然としてchiselサーバーをエンドツーエンドで認証します — CDNはトンネル化されたトラフィックを読み取ったり変更したりできません。--keepaliveをデフォルトの25sに保ち、CDNのアイドルタイムアウトを下回るようにしてください。また、Upgradeヘッダーを除去するプロキシはchiselをまったく運べないことに注意してください。
あまり一般的ではない調整項目は環境変数で、すべてCHISEL_プレフィックス付きで読み取られます(例:CHISEL_WS_TIMEOUT=10s):
| 変数 | サイド | デフォルト | 目的 |
|---|---|---|---|
WS_TIMEOUT | クライアント | 45s | websocketハンドシェイクタイムアウト |
SSH_TIMEOUT | クライアント | 30s | sshハンドシェイクタイムアウト |
CONFIG_TIMEOUT | サーバー | 10s | クライアントの設定リクエストを待つ時間 |
SSH_WAIT | 両方 | 35s | 新しいトンネルがアクティブな接続を待つ時間 |
PING_TIMEOUT | 両方 | keepalive間隔 | keepalive ping応答タイムアウト(--keepalive 0の場合はpingなし) |
DIAL_TIMEOUT | 出口ノード | 30s | トンネルターゲットへのtcpダイヤルタイムアウト |
WS_READ_LIMIT | 両方 | 524288 | 受信websocketメッセージの最大バイト数(0 = 制限なし、負数 = デフォルト) |
WS_BUFF_SIZE | 両方 | goデフォルト | websocket読み取り/書き込みバッファサイズ |
UDP_MAX_SIZE | 両方 | 9012 | 最大udpパケットバイト数 |
UDP_DEADLINE | 出口ノード | 15s | udpフローの読み取り期限とアイドルスイープ期間 |
UDP_MAX_CONNS | 出口ノード | 100 | トンネルあたりの最大同時udpフロー数 |
SHUTDOWN_GRACE | サーバー | 5s | シャットダウン時のhttpリクエスト排出時間 |
HOST、PORT、AUTH、およびCHISEL_KEY/CHISEL_KEY_FILEは、上記の--helpテキストに記載されています。
WebSocketsのサポートが必要なため:
github.com/jpillora/chisel/shareには共有パッケージが含まれていますgithub.com/jpillora/chisel/serverにはサーバーパッケージが含まれていますgithub.com/jpillora/chisel/clientにはクライアントパッケージが含まれています1.0 - 初回リリース1.1 - 単純な対称暗号化をECDSA SSHに置き換え1.2 - SOCKS5(サーバー)とHTTP CONNECT(クライアント)のサポートを追加1.3 - リバーストンネリングのサポートを追加1.4 - 任意のHTTPヘッダーサポートを追加1.5 - リバースSOCKSサポートを追加(@ausによる)1.6 - クライアントstdioサポートを追加(@BoleynSuによる)1.7 - UDPサポートを追加1.8 - scratchDockerイメージに移行1.9 - Go 1.21に更新。--keyシードから--key{gen,file}によるP256キー文字列に切り替え(@cmenginnzによる)1.10 - Go 1.22に更新。リリースに.rpm、.deb、.apkを追加。不正なバージョン比較を修正。1.11 - Go 1.25.1に更新。すべての依存関係を更新。1.12 - 信頼性とセキュリティのパス:
CHISEL_PING_TIMEOUT)、スリープ/ウェイク後、NATタイムアウト、サーバー再起動後に切断された接続が迅速に再接続されます--socks5 + --authfileを使用する場合、SOCKS5アクセスにはsocksに一致するauthfileエントリが必要になりました(ワイルドカード""エントリは引き続き機能します)--fingerprintは完全なSHA256形式(または完全な16オクテットのMD5コロン形式)である必要があります--auth user)は、認証を静かに無効化する代わりに起動時の致命的エラーになりますCHISEL_DIAL_TIMEOUT、デフォルト30秒)CHISEL_SHUTDOWN_GRACE)。2回目のシグナルで強制終了しますCHISEL_UDP_MAX_CONNS)1.11.x以前からアップグレードする場合、4つの変更で対応が必要になる場合があります:
--authfile(v1.11.7以降で強制):プロキシアクセスを維持すべきユーザーは、トークンsocksに一致するauthfileエントリが必要です(ワイルドカード""は引き続き機能します)。認証を参照してください。拒否されたリクエストはサーバー側でDenied connection to socks (ACL)として記録されます。--fingerprint:切り詰められたレガシーMD5フィンガープリントは拒否されます。サーバーとクライアントが出力する完全なSHA256フィンガープリントを使用してください(完全な16オクテットのMD5コロン形式は引き続き受け入れられますが、非推奨です)。--auth**の値は<user>:<pass>である必要があります — コロンを含まない文字列は、認証を静かに無効化する代わりに起動時に失敗するようになりました。--max-retry-count付きのchisel clientは、接続試行を使い果たすと非ゼロで終了するようになりました。$?をチェックするスクリプトやsystemdのRestart=on-failureユニットはこれに気付くでしょう。MIT © Jaime Pillora
CHISEL_WS_READ_LIMIT)--max-retry-countを使い果たすとクライアントは非ゼロで終了します。新しい--min-retry-interval(デフォルト1秒)。--proxyにsocks5://が受け入れられますgo installビルドは実際のバージョンを報告します。セッションと失敗したログインは情報レベルで記録されますx/crypto/sshはGO-2026-6303に対処するためv0.55.0に更新されていますlatest / X / X.Yタグが昇格します