Baike.dev
All toolsTrendingOpen sourceNewsSubmit
Log in
< 返回工具列表
C

chisel

> 编程语言
开源

A fast TCP/UDP tunnel over HTTP

16.3K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

A fast TCP/UDP tunnel over HTTP

Chisel

Chisel is a fast TCP/UDP tunnel, transported over HTTP, secured via SSH. Single executable including both client and server. Written in Go (golang). Chisel is mainly useful for passing through firewalls, though it can also be used to provide a secure endpoint into your network.

Table of Contents

  • Features
  • Install
  • Demo
  • Usage
  • Contributing
  • Changelog
  • License

Features

  • Easy to use
  • Performant*
  • Encrypted connections using the SSH protocol (via crypto/ssh)
  • Authenticated connections; authenticated client connections with a users config file, authenticated server connections with fingerprint matching.
  • Client auto-reconnects with exponential backoff (tunable via --min/max-retry-interval); keepalive pings time out, so silently dead connections (sleep/wake, NAT timeouts, server restarts) are detected and re-established
  • Clients can create multiple tunnel endpoints over one TCP connection
  • Clients can optionally pass through SOCKS or HTTP CONNECT proxies
  • Reverse port forwarding (Connections go through the server and out the client)
  • Server optionally doubles as a reverse proxy
  • Server optionally allows SOCKS5 connections (See guide below)
  • Clients optionally allow SOCKS5 connections from a reversed port forward
  • Client connections over stdio which supports ssh -o ProxyCommand providing SSH over HTTP

Install

Binaries

See the latest release or download and install it now with curl https://i.jpillora.com/chisel! | bash

Binaries are built with the latest Go release, which sets the minimum OS versions: Windows 10 / Server 2016, macOS 12, Linux kernel 3.2, FreeBSD 12.2. For older systems (e.g. Windows 7), use release v1.8.1 or earlier.

Docker

docker run --rm -it jpillora/chisel --help

Images are multi-arch and published to both Docker Hub (jpillora/chisel) and GitHub Container Registry (ghcr.io/jpillora/chisel).

Fedora

The package is maintained by the Fedora community. If you encounter issues related to the usage of the RPM, please use this issue tracker.

sudo dnf -y install chisel

Source

$ go install github.com/jpillora/chisel@latest

Demo

You can run your own demo server in minutes (the old Heroku demo went away with Heroku's free tier). example/fly.toml deploys this chisel server to fly.io's free allowance:

$ 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.:

$ chisel client https://<your-app>.fly.dev 3000
# connects to your chisel server,
# tunnels your localhost:3000 to the server's localhost:3000

Visiting your app's URL in a browser hits the server's default backend proxy and shows a copy of example.com.

Usage

$ 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
…
…

Security

Encryption is always enabled. When you start up a chisel server, it will generate an in-memory ECDSA public/private key pair. The public key fingerprint (base64 encoded SHA256) will be displayed as the server starts. Instead of generating a random key, the server may optionally specify a key file, using the --keyfile option. When clients connect, they will also display the server's public key fingerprint. The client can force a particular fingerprint using the --fingerprint option. Legacy MD5 fingerprints are still accepted but must be the full 16-octet colon form — truncated prefixes are rejected. See the --help above for more information.

The server also caps inbound websocket message sizes before authentication (CHISEL_WS_READ_LIMIT, default 512 KiB), so unauthenticated peers cannot exhaust memory with oversized messages. The default sits comfortably above x/crypto/ssh's 256 KiB maximum transport packet, so no valid SSH packet is ever rejected. Only 0 disables the limit; negative values fall back to the safe default.

Authentication

Using the --authfile option, the server may optionally provide a user.json configuration file to create a list of accepted users. The client then authenticates using the --auth option. See users.json for an example authentication configuration file. See the --help above for more information.

Notes on authfile behavior:

  • The file is watched and reloaded live — including editor saves via rename (vim) and kubernetes configmap updates. Reloads apply to new connections and to new tunnels of already-connected clients; removed users lose access to new tunnels immediately, though established tunnels are not interrupted.
  • Address patterns are regular expressions and are not anchored — anchor them with ^ and $ (the server warns about unanchored patterns at load). The empty string "" matches everything.
  • SOCKS5 access is controlled by an entry matching the token socks. Breaking: SOCKS5 previously bypassed the authfile entirely; servers running --socks5 with --authfile must grant socks to users who should keep proxy access (wildcard "" entries keep working).
  • Auth strings without a colon (user:pass) are now a fatal startup error on both server and client — previously they silently disabled authentication.
  • The --auth user survives authfile reloads and wins name clashes with file users.

Internally, this is done using the Password authentication method provided by SSH. Learn more about crypto/ssh here http://blog.gopheracademy.com/go-and-ssh/. Session opens/closes (with user, source address and remotes) and failed login attempts are logged at info level.

TLS Guide

The simplest secure setup is --tls-domain, which provisions a LetsEncrypt certificate automatically (requires port 443 and a DNS record pointing at the server):

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

To use your own certificate (self-signed or internal CA), generate a key/cert pair and point both sides at the right files:

chisel server --port 443 --tls-key key.pem --tls-cert cert.pem
chisel client --tls-ca ca.pem https://chisel.example.com 3000

For mutual TLS, also pass --tls-ca to the server and --tls-cert/--tls-key to each client. Note that TLS wraps chisel's transport from the outside; the inner SSH layer still encrypts and authenticates, so --fingerprint validation works with or without TLS.

SOCKS5 Guide with Docker

  1. Print a new private key to the terminal

    chisel server --keygen -
    # or save it to disk --keygen /path/to/mykey
    
  2. Start your chisel server

    jpillora/chisel server --keyfile '<ck-base64 string or file path>' -p 9312 --socks5
    
  3. Connect your chisel client (using server's fingerprint)

    chisel client --fingerprint '<see server output>' <server-address>:9312 socks
    
  4. Point your SOCKS5 clients (e.g. OS/Browser) to:

    <client-address>:1080
    
  5. Now you have an encrypted, authenticated SOCKS5 connection over HTTP

Note: if the server also uses --authfile, users need an entry matching the token socks to use the proxy (see Authentication).

Reverse SOCKS with an Authfile

To let a specific client act as a SOCKS exit node, grant it the reverse-socks listener address (R:socks listens on the server's 127.0.0.1:1080):

{
  "exituser:password": ["^R:127\\.0\\.0\\.1:1080$"]
}
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

See also the step-by-step reverse tunneling example.

Running behind a CDN (Cloudflare)

chisel works through CDNs that support WebSockets. For Cloudflare: enable WebSockets, proxy (orange-cloud) the DNS record, and connect clients with https://. The CDN terminates TLS, but the inner SSH layer means --fingerprint validation still authenticates your chisel server end-to-end — the CDN cannot read or modify tunneled traffic. Keep --keepalive at its 25s default to stay under CDN idle timeouts, and note that proxies which strip Upgrade headers cannot carry chisel at all.

Tuning with environment variables

Less common knobs are environment variables, all read with a CHISEL_ prefix (e.g. CHISEL_WS_TIMEOUT=10s):

Variable Side Default Purpose WS_TIMEOUT client 45s websocket handshake timeout SSH_TIMEOUT client 30s ssh handshake timeout CONFIG_TIMEOUT server 10s wait for the client's config request SSH_WAIT both 35s how long new tunnels wait for an active connection PING_TIMEOUT both keepalive interval keepalive ping reply timeout (no pings if --keepalive 0) DIAL_TIMEOUT exit node 30s tcp dial timeout for tunnel targets WS_READ_LIMIT both 524288 max inbound websocket message bytes (0 = no limit; negative = default) WS_BUFF_SIZE both go default websocket read/write buffer sizes UDP_MAX_SIZE both 9012 max udp packet bytes UDP_DEADLINE both 15s udp flow read deadline and return-peer expiry UDP_MAX_CONNS both 100 max udp flows or return peers per tunnel SHUTDOWN_GRACE server 5s http request drain time on shutdown

HOST, PORT, AUTH, and CHISEL_KEY/CHISEL_KEY_FILE are documented in the --help texts above.

Caveats

Since WebSockets support is required:

  • IaaS providers all will support WebSockets (unless an unsupporting HTTP proxy has been forced in front of you, in which case I'd argue that you've been downgraded to PaaS)
  • PaaS providers vary in their support for WebSockets
    • Heroku has full support
    • Openshift has full support though connections are only accepted on ports 8443 and 8080
    • Google App Engine standard has no support (the flexible environment does)

Contributing

  • http://golang.org/doc/code.html
  • http://golang.org/doc/effective_go.html
  • github.com/jpillora/chisel/share contains the shared package
  • `github.com/jpillora/chisel/serve

核心特点

  • •Features
  • •Contributing
  • •Changelog
  • •Easy to use
  • •Performant\
  • •Encrypted connections using the SSH protocol (via crypto/ssh)
  • •Authenticated connections; authenticated client connections with a users config file, authenticated server connections with fingerprint matching.
  • •Clients can create multiple tunnel endpoints over one TCP connection
  • •Clients can optionally pass through SOCKS or HTTP CONNECT proxies
  • •Reverse port forwarding (Connections go through the server and out the client)

> 标签

Gogolanghttptcptunnel

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月9日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言
Baike.dev

baike.dev helps you discover great languages, frameworks, databases, DevOps and cloud-native tools.

Quick links

  • Home
  • All tools
  • Trending
  • Open source

About

  • About us
  • Community
  • News

Contribute

Found a great developer tool? Share it with the community.

Submit a tool
© 2026 baike.dev Developer EncyclopediaUpdated daily · Discover great developer tools