Command-Line Flags

Quick reference for all Ghostunnel command-line flags, grouped by mode. For detailed usage of specific features, see the linked documentation pages.

Global Flags

These flags are available in both server and client modes.

Certificate / Key

See Certificate Formats for details on supported file formats and chain ordering.

FlagDescription
--keystore PATHPath to keystore (combined PEM with cert/key, or PKCS12 keystore).
--cert PATHPath to certificate (PEM with certificate chain).
--key PATHPath to certificate private key (PEM with private key).
--storepass PASSPassword for keystore (if using PKCS12 keystore, optional).
--cacert PATHPath to CA bundle file (PEM/X509). Uses system trust store by default.
--use-workload-apiCertificate and root CAs are retrieved via the SPIFFE Workload API. See SPIFFE.
--use-workload-api-addr ADDRRetrieve certificates and root CAs via the SPIFFE Workload API at the specified address (implies --use-workload-api). See SPIFFE.

Keychain

These flags are only available on platforms with keychain support. See Keychain.

FlagDescriptionAvailability
--keychain-identity NAMEUse local keychain identity with given common name or serial number.macOS, Windows
--keychain-issuer NAMEUse local keychain identity with given issuer common name.macOS, Windows
--keychain-require-tokenRequire keychain identity to be from a physical token.macOS only

PKCS#11

These flags require a build with CGO enabled. See HSM/PKCS#11.

FlagDescriptionAvailability
--pkcs11-module PATHPath to PKCS#11 module (.so) file.Requires CGO
--pkcs11-token-label LABELToken label for slot/key in PKCS#11 module.Requires CGO
--pkcs11-pin PINPIN code for slot/key in PKCS#11 module.Requires CGO

Timeouts

FlagDefaultDescription
--timed-reload DURATIONReload keystores every given interval, refresh listener/client on changes.
--shutdown-timeout DURATION5mProcess shutdown timeout. Terminates after timeout even if connections are still open.
--connect-timeout DURATION10sTimeout for establishing connections and handshakes.
--close-timeout DURATION1sTimeout for closing connections when one side terminates. Zero means immediate closure.
--max-conn-lifetime DURATION0sMaximum lifetime for connections post handshake. Zero means infinite.
--max-concurrent-conns N0Maximum number of concurrent connections. Zero means infinite.

Metrics

See Metrics.

FlagDefaultDescription
--metrics-graphite ADDRCollect metrics and report to the given Graphite instance (raw TCP).
--metrics-url URLCollect metrics and POST them periodically to the given URL (HTTP/JSON).
--metrics-prefix PREFIXghostunnelPrefix string for all reported metrics.
--metrics-interval DURATION30sCollect (and post/send) metrics every specified interval.

Status / Logging

See Metrics & Profiling for details on the status port, metrics endpoints, and profiling.

FlagDescriptionAvailability
--status ADDREnable /_status and /_metrics on given HOST:PORT (or unix:SOCKET).All platforms
--enable-pprofEnable /debug/pprof endpoints alongside /_status (for profiling).All platforms
--enable-shutdownEnable /_shutdown endpoint alongside /_status to allow terminating via HTTP POST.All platforms
--quietSilence log messages. Values: all, conns, conn-errs, handshake-errs. Can be repeated.All platforms
--syslogSend logs to syslog instead of stdout.Linux, macOS
--skip-resolveSkip resolving target host on startup (useful to start before network is up).All platforms

Landlock

See Security & TLS Configuration for details on Landlock sandboxing.

FlagDescriptionAvailability
--disable-landlockDisable the best-effort Landlock sandboxing. Landlock is automatically disabled when PKCS#11 is used.Linux only

Server Mode Flags

Flags specific to ghostunnel server.

Required

See Socket Activation for systemd:NAME and launchd:NAME addresses.

FlagDescription
--listen ADDRAddress and port to listen on (HOST:PORT, unix:PATH, systemd:NAME, or launchd:NAME).
--target ADDRAddress to forward connections to (HOST:PORT or unix:PATH).

Proxying

See PROXY Protocol for details on modes and TLV extensions.

FlagDescription
--target-status URLAddress to target for status checking downstream healthchecks. Defaults to TCP healthcheck if not passed.
--proxy-protocolEnable PROXY protocol v2 with connection info only (equivalent to --proxy-protocol-mode=conn).
--proxy-protocol-mode MODEPROXY protocol v2 mode: conn, tls, or tls-full. Mutually exclusive with --proxy-protocol.
--unsafe-targetDo not limit target to localhost, 127.0.0.1, [::1], or UNIX sockets. See Security.

Access Control

See Access Control Flags.

FlagDescription
--allow-allAllow all clients, do not check client cert subject.
--allow-cn CNAllow clients with given common name (repeatable).
--allow-ou OUAllow clients with given organizational unit name (repeatable).
--allow-dns DNSAllow clients with given DNS subject alternative name (repeatable).
--allow-uri URIAllow clients with given URI subject alternative name (repeatable).
--disable-authenticationDisable client authentication, no client certificate will be required.

ACME (Server)

See ACME Support.

FlagDescription
--auto-acme-cert FQDNAutomatically obtain a certificate via ACME for the specified FQDN.
--auto-acme-email EMAILEmail address associated with all ACME requests.
--auto-acme-agree-to-tosAgree to the Terms of Service of the ACME CA.
--auto-acme-ca URLURL of the ACME CA. Defaults to Let’s Encrypt if not specified.
--auto-acme-testca URLURL of the ACME CA’s test/staging environment. If set, --auto-acme-ca is ignored.

OPA Policy (Server)

See Access Control Flags for OPA/Rego policy details.

FlagDescription
--allow-policy BUNDLELocation of an OPA policy bundle.
--allow-query QUERYRego query to validate against the client certificate and the policy.

Client Mode Flags

Flags specific to ghostunnel client.

Required

See Socket Activation for systemd:NAME and launchd:NAME addresses.

FlagDescription
--listen ADDRAddress and port to listen on (HOST:PORT, unix:PATH, systemd:NAME, or launchd:NAME).
--target ADDRAddress to forward connections to (must be HOST:PORT).

Connection

FlagDescription
--unsafe-listenDo not limit listen to localhost, 127.0.0.1, [::1], or UNIX sockets. See Security.
--override-server-name NAMEOverride the server name used for hostname verification.
--proxy URLConnect to target over given proxy (HTTP CONNECT or SOCKS5). Must be a proxy URL.
--disable-authenticationDisable client authentication, no certificate will be provided to the server.

Server Verification

See Access Control Flags.

FlagDescription
--verify-cn CNAllow servers with given common name (repeatable).
--verify-ou OUAllow servers with given organizational unit name (repeatable).
--verify-dns DNSAllow servers with given DNS subject alternative name (repeatable).
--verify-uri URIAllow servers with given URI subject alternative name (repeatable).

OPA Policy (Client)

See Access Control Flags for OPA/Rego policy details.

FlagDescription
--verify-policy BUNDLELocation of an OPA policy bundle.
--verify-query QUERYRego query to evaluate against the server certificate and the policy.

Environment Variables

Several flags can also be set via environment variables.

VariableFlag
KEYSTORE_PATH--keystore
CERT_PATH--cert
KEY_PATH--key
KEYSTORE_PASS--storepass
CACERT_PATH--cacert
SPIFFE_ENDPOINT_SOCKET--use-workload-api-addr
PKCS11_MODULE--pkcs11-module
PKCS11_TOKEN_LABEL--pkcs11-token-label
PKCS11_PIN--pkcs11-pin