
Tunnel TCP/UDP veloce su HTTP con crittografia SSH, supporta reverse port forwarding, proxy SOCKS5 e autenticazione client per un attraversamento sicuro della rete e l'elusione dei firewall.
Chisel è un tunnel TCP/UDP veloce, trasportato su HTTP e protetto via SSH. Un singolo eseguibile include sia client che server. Scritto in Go (golang). Chisel è utile principalmente per attraversare firewall, ma può anche essere usato per fornire un endpoint sicuro verso la propria rete.

crypto/ssh)--min/max-retry-interval); i ping di keepalive vanno in timeout, quindi le connessioni silenziosamente morte (sospensione/riattivazione, timeout NAT, riavvii del server) vengono rilevate e ristabilitessh -o ProxyCommand, fornendo SSH su HTTPVedi l'ultima release oppure scaricala e installala subito con curl https://i.jpillora.com/chisel! | bash
I binari sono compilati con l'ultima versione di Go, che stabilisce le versioni minime dei sistemi operativi: Windows 10 / Server 2016, macOS 12, kernel Linux 3.2, FreeBSD 12.2. Per sistemi più vecchi (es. Windows 7), usa la release v1.8.1 o precedenti.
```sh
docker run --rm -it jpillora/chisel --help
Le immagini sono multi-architettura e pubblicate sia su Docker Hub (`jpillora/chisel`) che su GitHub Container Registry (`ghcr.io/jpillora/chisel`).
### Fedora
Il pacchetto è mantenuto dalla comunità Fedora. Se incontri problemi relativi all'uso del RPM, utilizza questo [issue tracker](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
## Demo
Puoi eseguire il tuo server demo in pochi minuti (la vecchia demo Heroku è scomparsa con il piano gratuito di Heroku). [`example/fly.toml`](https://github.com/jpillora/chisel/blob/HEAD/example/fly.toml) distribuisce questo `chisel server` sulla quota gratuita di [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
Distribuiscilo con fly launch --copy-config dalla directory example/, quindi crea un tunnel verso qualsiasi servizio in esecuzione accanto al server, ad esempio:```sh
$ chisel client https://.fly.dev 3000
Visitando l'URL della tua app in un browser, si raggiunge il proxy backend predefinito del server e viene mostrata una copia di [example.com](http://example.com).
## Utilizzo
<!-- renderizza questi testi di aiuto a mano,
oppure usa https://github.com/jpillora/md-tmpl
con $ 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
La crittografia è sempre attiva. Quando avvii un server chisel, questo genera una coppia di chiavi ECDSA pubblica/privata in memoria. L'impronta della chiave pubblica (SHA256 codificato in base64) viene mostrata all'avvio del server. Invece di generare una chiave casuale, il server può facoltativamente specificare un file di chiave usando l'opzione --keyfile. Quando i client si connettono, mostrano anch'essi l'impronta della chiave pubblica del server. Il client può imporre un'impronta specifica usando l'opzione --fingerprint. Le vecchie impronte MD5 sono ancora accettate ma devono essere nella forma completa a 16 ottetti separati da due punti — i prefissi troncati vengono rifiutati. Vedi --help qui sopra per maggiori informazioni.
Il server limita inoltre la dimensione dei messaggi websocket in entrata prima dell'autenticazione (CHISEL_WS_READ_LIMIT, default 512 KiB), così i peer non autenticati non possono esaurire la memoria con messaggi sovradimensionati. Il default è ampiamente al di sopra del massimo pacchetto di trasporto di 256 KiB di x/crypto/ssh, quindi nessun pacchetto SSH valido viene mai rifiutato. Solo 0 disabilita il limite; i valori negativi ripiegano sul default sicuro.
Usando l'opzione --authfile, il server può facoltativamente fornire un file di configurazione user.json per creare un elenco di utenti accettati. Il client si autentica quindi usando l'opzione --auth. Vedi users.json per un esempio di file di configurazione dell'autenticazione. Vedi --help qui sopra per maggiori informazioni.
Note sul comportamento di authfile:
^ e $ (il server avvisa sui pattern non ancorati al caricamento). La stringa vuota "" corrisponde a tutto.socks. Modifica incompatibile: SOCKS5 in precedenza bypassava completamente l'authfile; i server che eseguono --socks5 con --authfile devono concedere socks agli utenti che devono mantenere l'accesso proxy (le voci con carattere jolly "" continuano a funzionare).user:pass) ora sono un errore fatale all'avvio sia sul server che sul client — in precedenza disabilitavano silenziosamente l'autenticazione.--auth sopravvive ai ricaricamenti dell'authfile e vince nei conflitti di nome con gli utenti del file.Internamente, questo viene fatto usando il metodo di autenticazione Password fornito da SSH. Scopri di più su crypto/ssh qui http://blog.gopheracademy.com/go-and-ssh/. Le aperture/chiusure delle sessioni (con utente, indirizzo sorgente e remoti) e i tentativi di accesso falliti vengono registrati a livello informativo.
La configurazione sicura più semplice è --tls-domain, che provvede automaticamente a un certificato LetsEncrypt (richiede la porta 443 e un record DNS che punta al server):```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
Per usare il tuo certificato (autofirmato o CA interna), genera una coppia chiave/certificato e fai puntare entrambi i lati ai file giusti:```sh
chisel server --port 443 --tls-key key.pem --tls-cert cert.pem
chisel client --tls-ca ca.pem https://chisel.example.com 3000
Per la TLS reciproca, passa anche --tls-ca al server e --tls-cert/--tls-key a ciascun client. Nota che la TLS avvolge il trasporto di chisel dall'esterno; il livello SSH interno continua a crittografare e autenticare, quindi la validazione di --fingerprint funziona con o senza TLS.
Stampa una nuova chiave privata sul terminale
chisel server --keygen -
# or save it to disk --keygen /path/to/mykey
Avvia il tuo server chisel
jpillora/chisel server --keyfile '<ck-base64 string or file path>' -p 9312 --socks5
Collega il tuo client chisel (usando l'impronta digitale del server)
chisel client --fingerprint '<see server output>' <server-address>:9312 socks
Indirizza i tuoi client SOCKS5 (es. OS/browser) a:
<client-address>:1080
Ora hai una connessione SOCKS5 crittografata e autenticata su HTTP
Nota: se il server usa anche --authfile, gli utenti devono avere una voce corrispondente al token socks per usare il proxy (vedi Autenticazione).
Per consentire a un client specifico di fungere da nodo di uscita SOCKS, concedigli l'indirizzo di ascolto reverse-socks (R:socks ascolta su 127.0.0.1:1080 del server):```json
{
"exituser:password": ["^R:127\.0\.0\.1:1080$"]
}
Please provide the Markdown content to translate.```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
Vedi anche l'esempio passo-passo di reverse tunneling.
chisel funziona attraverso CDN che supportano WebSockets. Per Cloudflare: abilita WebSockets, imposta il record DNS come proxy (nuvola arancione) e collega i client con https://. La CDN termina TLS, ma il livello SSH interno fa sì che la validazione di --fingerprint autentichi comunque il tuo server chisel end-to-end — la CDN non può leggere o modificare il traffico in tunnel. Mantieni --keepalive sul default di 25s per restare sotto i timeout di inattività della CDN, e nota che i proxy che rimuovono gli header Upgrade non possono trasportare chisel.
Le impostazioni meno comuni sono variabili d'ambiente, tutte lette con un prefisso CHISEL_ (es. CHISEL_WS_TIMEOUT=10s):
HOST, PORT, AUTH e CHISEL_KEY/CHISEL_KEY_FILE sono documentati nei testi di --help qui sopra.
Poiché è richiesto il supporto WebSockets:
github.com/jpillora/chisel/share contiene il pacchetto condivisogithub.com/jpillora/chisel/server contiene il pacchetto servergithub.com/jpillora/chisel/client contiene il pacchetto client1.0 - Rilascio iniziale1.1 - Sostituita la semplice cifratura simmetrica con ECDSA SSH1.2 - Aggiunto supporto a SOCKS5 (server) e HTTP CONNECT (client)1.3 - Aggiunto supporto al reverse tunnelling1.4 - Aggiunto supporto per header HTTP arbitrari1.5 - Aggiunto supporto SOCKS inverso (di @aus)1.6 - Aggiunto supporto stdio al client (di @BoleynSu)1.7 - Aggiunto supporto UDP1.8 - Migrazione a un'immagine Docker scratch1.9 - Aggiornamento a Go 1.21. Passaggio dal seed --key alle stringhe di chiave P256 con --key{gen,file} (di @cmenginnz)Quattro modifiche potrebbero richiedere interventi quando si aggiorna da 1.11.x o versioni precedenti:
--authfile (applicato dalla v1.11.7): gli utenti che devono mantenere l'accesso proxy necessitano di una voce authfile corrispondente al token socks (il wildcard "" continua a funzionare). Vedi Autenticazione. Le richieste negate vengono registrate lato server come Denied connection to socks (ACL).--fingerprint: le impronte MD5 legacy troncate vengono rifiutate. Usa l'impronta SHA256 completa stampata da server e client (la forma MD5 completa a 16 ottetti con due punti è ancora accettata, ma deprecata).--auth: i valori devono essere <user>:<pass> — le stringhe senza due punti ora falliscono all'avvio invece di disabilitare silenziosamente l'autenticazione.chisel client con --max-retry-count ora esce con codice diverso da zero quando i tentativi di connessione sono esauriti; gli script che controllano $? e le unità systemd Restart=on-failure lo noteranno.MIT © Jaime Pillora
| Variable | Side | Default | Purpose |
|---|
WS_TIMEOUT | client | 45s | timeout handshake websocket |
SSH_TIMEOUT | client | 30s | timeout handshake ssh |
CONFIG_TIMEOUT | server | 10s | attesa della richiesta di configurazione del client |
SSH_WAIT | entrambi | 35s | per quanto tempo i nuovi tunnel attendono una connessione attiva |
PING_TIMEOUT | entrambi | intervallo keepalive | timeout di risposta al ping keepalive (nessun ping se --keepalive 0) |
DIAL_TIMEOUT | nodo di uscita | 30s | timeout dial tcp per i target del tunnel |
WS_READ_LIMIT | entrambi | 524288 | byte massimi dei messaggi websocket in ingresso (0 = nessun limite; negativo = default) |
WS_BUFF_SIZE | entrambi | default di Go | dimensioni dei buffer di lettura/scrittura websocket |
UDP_MAX_SIZE | entrambi | 9012 | byte massimi dei pacchetti udp |
UDP_DEADLINE | nodo di uscita | 15s | scadenza di lettura dei flussi udp ed età di sweep degli idle |
UDP_MAX_CONNS | nodo di uscita | 100 | massimo di flussi udp concorrenti per tunnel |
SHUTDOWN_GRACE | server | 5s | tempo di drenaggio delle richieste http allo spegnimento |
1.10 - Aggiornamento a Go 1.22. Aggiunti .rpm .deb e .apk alle release. Correzione del confronto versioni errato.1.11 - Aggiornamento a Go 1.25.1. Aggiornate tutte le dipendenze.1.12 - (non rilasciato) Miglioramenti di affidabilità e sicurezza:
CHISEL_PING_TIMEOUT), quindi le connessioni morte si riconnettono prontamente dopo sleep/wake, timeout NAT e riavvii del server--socks5 + --authfile, l'accesso SOCKS5 ora richiede una voce authfile corrispondente a socks (le voci wildcard "" continuano a funzionare)--fingerprint deve essere nella forma SHA256 completa (o nella forma MD5 completa a 16 ottetti con i due punti)--auth user) ora causano un errore fatale all'avvio invece di disabilitare silenziosamente l'autenticazioneCHISEL_DIAL_TIMEOUT, default 30s)CHISEL_SHUTDOWN_GRACE); un secondo segnale forza l'uscitaCHISEL_UDP_MAX_CONNS)CHISEL_WS_READ_LIMIT)--max-retry-count è esaurito; nuovo --min-retry-interval (default 1s); socks5:// accettato per --proxygo install riportano la versione reale; sessioni e login falliti vengono registrati a livello infolatest / X / X.Y