Convert Figma logo to code with AI

jpillora logochisel

A fast TCP/UDP tunnel over HTTP

12,696
1,337
12,696
229

Top Related Projects

84,231

A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.

24,128

Unified ingress for developers

Minimal, self-hosted, 0-config alternative to ngrok. Caddy+OpenSSH+50 lines of Python.

4,520

Applicative Protocol Multiplexer (e.g. share SSH and HTTPS on the same port)

15,747

GO Simple Tunnel - a simple tunnel written in golang

30,258

一款轻量级、高性能、功能强大的内网穿透代理服务器。支持tcp、udp、socks5、http等几乎所有流量转发,可用来访问内网网站、本地支付接口调试、ssh访问、远程桌面,内网dns解析、内网socks5代理等等……,并带有功能强大的web管理端。a lightweight, high-performance, powerful intranet penetration proxy server, with a powerful web management terminal.

Quick Overview

Chisel is a fast TCP/UDP tunnel, transported over HTTP, secured via SSH. It's designed to be a user-friendly alternative to VPNs and SSH tunnels, allowing for easy setup of secure connections through firewalls. Chisel can be used for various networking tasks, including port forwarding and creating SOCKS proxies.

Pros

  • Easy to use and set up, with a simple command-line interface
  • Supports both client and server modes
  • Provides secure tunneling using SSH encryption
  • Works well in restricted network environments, bypassing firewalls

Cons

  • Requires installation and setup on both client and server sides
  • May be blocked by some corporate firewalls that specifically filter HTTP tunneling
  • Limited documentation for advanced use cases
  • Potential security risks if not configured properly

Getting Started

  1. Install Chisel:

    go install github.com/jpillora/chisel@latest
    
  2. Start a Chisel server:

    chisel server -p 8080 --auth user:pass
    
  3. Connect a Chisel client:

    chisel client --auth user:pass server.com:8080 3000:example.com:80
    

This setup creates a tunnel from localhost:3000 on the client to example.com:80 through the Chisel server. Adjust the ports and hostnames as needed for your specific use case.

Competitor Comparisons

84,231

A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.

Pros of frp

  • More comprehensive feature set, including load balancing and custom plugins
  • Supports multiple protocols (TCP, UDP, HTTP, HTTPS, STCP, KCP)
  • Better suited for complex networking scenarios and enterprise environments

Cons of frp

  • Steeper learning curve due to more configuration options
  • Larger codebase, potentially leading to more maintenance and slower updates
  • May be overkill for simple port forwarding tasks

Code Comparison

frp configuration example:

[common]
server_addr = x.x.x.x
server_port = 7000

[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6000

Chisel command-line example:

chisel server -p 8080 --reverse
chisel client server.com:8080 R:socks

Key Differences

  • frp offers a more feature-rich solution with extensive configuration options
  • Chisel provides a simpler, command-line-driven approach for quick setups
  • frp is better for complex networking scenarios, while Chisel excels in simplicity and ease of use
  • Both projects are actively maintained, but frp has a larger community and more frequent updates

Use Cases

  • Choose frp for enterprise environments or when advanced features are required
  • Opt for Chisel in scenarios where quick setup and minimal configuration are priorities
24,128

Unified ingress for developers

Pros of ngrok

  • More user-friendly setup and configuration
  • Offers a robust free tier with additional features
  • Provides detailed analytics and inspection of traffic

Cons of ngrok

  • Closed-source, limiting customization options
  • Requires an account and authentication for usage
  • May have bandwidth limitations on free plans

Code Comparison

ngrok:

ngrok http 80

chisel:

chisel server -p 8080 --reverse
chisel client localhost:8080 R:80:localhost:80

Key Differences

  • ngrok is a hosted service, while chisel is self-hosted
  • chisel offers more flexibility for advanced networking scenarios
  • ngrok provides a simpler setup for basic port forwarding needs
  • chisel supports SSH tunneling, while ngrok focuses on HTTP/HTTPS
  • ngrok offers a web interface for managing tunnels, chisel relies on command-line

Both tools serve similar purposes but cater to different use cases. ngrok is ideal for quick, hassle-free tunneling, especially for development and testing. chisel is better suited for more complex networking requirements and situations where self-hosting is preferred or necessary.

Minimal, self-hosted, 0-config alternative to ngrok. Caddy+OpenSSH+50 lines of Python.

Pros of SirTunnel

  • Simpler setup and usage, especially for non-technical users
  • Built-in web interface for easy management
  • Focuses on HTTP/HTTPS tunneling, which may be sufficient for many use cases

Cons of SirTunnel

  • Limited protocol support compared to Chisel's versatility
  • Less actively maintained and smaller community
  • Fewer advanced features and customization options

Code Comparison

SirTunnel (JavaScript):

const tunnel = new SirTunnel({
  localPort: 8080,
  remoteHost: 'example.com',
  remotePort: 80
});
tunnel.start();

Chisel (Go):

client, err := chisel.NewClient(config)
if err != nil {
    log.Fatal(err)
}
err = client.Run()

Summary

SirTunnel offers a more user-friendly approach with its web interface and simpler setup, making it ideal for basic HTTP/HTTPS tunneling needs. However, Chisel provides broader protocol support, more advanced features, and is more actively maintained. Chisel's flexibility and robustness make it better suited for complex networking scenarios and power users, while SirTunnel's simplicity may be preferable for quick, straightforward tunneling tasks.

4,520

Applicative Protocol Multiplexer (e.g. share SSH and HTTPS on the same port)

Pros of sslh

  • Designed specifically for multiplexing SSL and SSH traffic on the same port
  • Lightweight and efficient, with minimal resource usage
  • Supports a wide range of protocols beyond just SSL and SSH

Cons of sslh

  • Limited to port forwarding and protocol detection
  • Less flexible for creating complex tunnels or proxies
  • Requires more manual configuration for advanced setups

Code Comparison

sslh configuration example:

listen:
  - { host: "0.0.0.0", port: "443" }
protocols:
  - name: ssh
    host: "localhost"
    port: "22"
  - name: ssl
    host: "localhost"
    port: "8443"

Chisel client command:

chisel client --auth user:pass https://example.com 3000:internal-service:80

Key Differences

  • sslh focuses on protocol detection and port forwarding, while Chisel provides a more versatile tunneling solution
  • Chisel offers built-in encryption and authentication, whereas sslh relies on the protocols it's forwarding for security
  • sslh is better suited for simple setups where you need to run multiple services on a single port, while Chisel excels in creating secure tunnels through firewalls

Both tools have their strengths, and the choice between them depends on the specific use case and requirements of your project.

15,747

GO Simple Tunnel - a simple tunnel written in golang

Pros of gost

  • Supports a wider range of protocols (HTTP, HTTPS, SOCKS4(A), SOCKS5, SS)
  • More flexible configuration options and chaining capabilities
  • Built-in web-based management interface for easier control

Cons of gost

  • More complex setup and configuration compared to chisel's simplicity
  • Potentially steeper learning curve for new users
  • Less focused on specific use cases, which may lead to feature bloat

Code Comparison

gost:

gost.Run(flags.Args()...)

chisel:

chisel.Run(config)

Key Differences

  • gost offers a broader range of features and protocols, making it more versatile for various networking scenarios
  • chisel focuses on simplicity and ease of use, particularly for SSH tunneling and port forwarding
  • gost provides a web interface for management, while chisel relies on command-line configuration
  • chisel may be easier to set up for basic tunneling needs, while gost offers more advanced options for complex networking requirements

Both projects serve similar purposes but cater to different user needs and preferences. gost is more suitable for users requiring extensive protocol support and advanced configurations, while chisel is ideal for those seeking a straightforward tunneling solution.

30,258

一款轻量级、高性能、功能强大的内网穿透代理服务器。支持tcp、udp、socks5、http等几乎所有流量转发,可用来访问内网网站、本地支付接口调试、ssh访问、远程桌面,内网dns解析、内网socks5代理等等……,并带有功能强大的web管理端。a lightweight, high-performance, powerful intranet penetration proxy server, with a powerful web management terminal.

Pros of nps

  • More comprehensive feature set, including web management interface
  • Supports multiple protocols (TCP, UDP, HTTP, HTTPS, SOCKS5)
  • Built-in load balancing and traffic statistics

Cons of nps

  • More complex setup and configuration
  • Larger codebase, potentially harder to audit
  • May be overkill for simple port forwarding needs

Code Comparison

nps client configuration:

[common]
server_addr=1.1.1.1:8024
vkey=123

Chisel client command:

chisel client server.com:8080 R:80:localhost:80

Key Differences

  • nps offers a more feature-rich solution with a web interface, while Chisel focuses on simplicity and ease of use
  • nps supports multiple protocols, whereas Chisel primarily uses HTTP/HTTPS
  • Chisel is written in Go, while nps uses a combination of Go and JavaScript
  • nps requires more setup but provides more advanced features like load balancing
  • Chisel is better suited for quick, simple tunneling tasks, while nps is more appropriate for complex networking scenarios

Both projects aim to solve similar problems but cater to different use cases and complexity levels. The choice between them depends on the specific requirements of the project and the user's familiarity with networking concepts.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Chisel

GoDoc CI

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.

overview

Table of Contents

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
  • 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

Releases Releases

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

Docker

Docker Pulls Image Size

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

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

A demo app on Heroku is running this chisel server:

$ chisel server --port $PORT --proxy http://example.com
# listens on $PORT, proxy web requests to http://example.com

This demo app is also running a simple file server on :3000, which is normally inaccessible due to Heroku's firewall. However, if we tunnel in with:

$ chisel client https://chisel-demo.herokuapp.com 3000
# connects to chisel server at https://chisel-demo.herokuapp.com,
# tunnels your localhost:3000 to the server's localhost:3000

and then visit localhost:3000, we should see a directory listing. Also, if we visit the demo app in the browser we should hit the server's default proxy and see 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

$ 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 fallsback 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 an inline base64 private key (e.g. chisel server --keygen - | base64).

    --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. Addresses will
    always come in the form "<remote-host>:<remote-port>" for normal remotes
    and "R:<local-interface>:<local-port>" for reverse port forwarding
    remotes. This file will be automatically reloaded on change.

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

    --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 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 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 0.0.0.0 (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 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' \
          user@example.com
    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 (=).

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

    --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.
    For example, http://admin:password@my-server.com:8081
            or: socks://admin:password@my-server.com:1080

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

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. See the --help above for more information.

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.

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/.

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

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 has no support (Track this on their repo)

Contributing

Changelog

  • 1.0 - Initial release
  • 1.1 - Replaced simple symmetric encryption for ECDSA SSH
  • 1.2 - Added SOCKS5 (server) and HTTP CONNECT (client) support
  • 1.3 - Added reverse tunnelling support
  • 1.4 - Added arbitrary HTTP header support
  • 1.5 - Added reverse SOCKS support (by @aus)
  • 1.6 - Added client stdio support (by @BoleynSu)
  • 1.7 - Added UDP support
  • 1.8 - Move to a scratchDocker image
  • 1.9 - Bump to Go 1.21. Switch from --key seed to P256 key strings with --key{gen,file} (by @cmenginnz)
  • 1.10 - Bump to Go 1.22. Add .rpm .deb and .akp to releases. Fix bad version comparison.

License

MIT © Jaime Pillora