Skip to main content

SSH Tunnel Switch

Rotate SSH SOCKS5 tunnels through a REST API or CLI. The built-in HTTP proxy forwards HTTP requests and HTTPS CONNECT traffic through the active tunnel, using SOCKS5 for remote DNS resolution.

The server runs independently and requires Python 3.12+ and OpenSSH. No OpenCode, Node.js, Bun or plugin is required.

Install and run

python3 -m venv .venv
.venv/bin/python -m pip install ssh-tunnel-switch
.venv/bin/tunnel-switch init-config --output config.yaml

init-config is available from version 1.0.0. It creates a mode-0600 example and refuses to overwrite existing files. For 0.1.0, download the example configuration and protect it with chmod 600 config.yaml.

Edit the SSH host aliases in the YAML. Verify host keys and key/agent authentication using your normal SSH client before starting the service. SSH accounts must allow TCP forwarding. Existing ~/.ssh/config settings apply when YAML does not override them.

.venv/bin/tunnel-switch validate --config config.yaml
.venv/bin/tunnel-switch serve --config config.yaml

Startup generates and saves an API token if needed and prints it to the console. Keep the configuration and logs private. By default the SOCKS5 listener is 127.0.0.1:1080, the HTTP proxy is 127.0.0.1:8118, and the REST API is 127.0.0.1:8765.

Use the proxy

curl --proxy http://127.0.0.1:8118 https://example.com/
.venv/bin/tunnel-switch status --config config.yaml
.venv/bin/tunnel-switch rotate --config config.yaml

Proxy-aware applications can use HTTP_PROXY and HTTPS_PROXY set to http://127.0.0.1:8118; set NO_PROXY=localhost,127.0.0.1,::1 for direct local control calls. SOCKS-aware clients can use socks5h://127.0.0.1:1080 directly. HTTPS remains encrypted end to end. Forwarding fails when SOCKS is unavailable and never falls back to a direct destination connection.

The bearer token protects the REST API only. HTTP and SOCKS proxy listeners are unauthenticated: retain loopback defaults or restrict access with a firewall. Protect remote REST access with TLS. See the security policy.

Guides

License

MIT.

Metadata

Release files for ssh-tunnel-switch 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ssh-tunnel-switch 1.0.0
File Size Uploaded
ssh_tunnel_switch-1.0.0.tar.gz 82.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ssh-tunnel-switch 1.0.0
File Interpreter ABI Platform
ssh_tunnel_switch-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 98.4 kB

Release files / ssh_tunnel_switch-1.0.0.tar.gz

Download URL ssh_tunnel_switch-1.0.0.tar.gz
Size 82.1 kB
Tags Source
SHA-256 checksum
How to use checksums
92ce9d5173076cd7bce9557d66ca75a5f950f5b7c35a7825741699d3d1ee871d
BLAKE2b-256 checksum
How to use checksums
abfc4c140fbbb60db3727434517976c09241e1d082c15b487f8adc859d7d25cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / ssh_tunnel_switch-1.0.0-py3-none-any.whl

Download URL ssh_tunnel_switch-1.0.0-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2a52c8bffecb33ba3a1d5c61a901a784e97d64c265bdc2d6dc6c0961fc4bc928
BLAKE2b-256 checksum
How to use checksums
9bd27eab9f7de8bab12beae5217db1ad144f55b56648d5c1c58875755d1ce780
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page