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. On an interactive terminal serve shows a live status panel while timestamped service and access logs are written to the log file (logging.file); when run under systemd the timestamped lines also reach the journal. 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.1.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.1.0
File Size Uploaded Provenance Actions
ssh_tunnel_switch-1.1.0.tar.gz 89.8 kB With provenance Details for ssh_tunnel_switch-1.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 110.6 kB

Release files / ssh_tunnel_switch-1.1.0.tar.gz

Download URL ssh_tunnel_switch-1.1.0.tar.gz
Size 89.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d44dcdf751f6593a6076620447c040bdfb46da4d438411c1656bf63754bcad0f
BLAKE2b-256 checksum
How to use checksums
cee1b96fb874bdba5f59586682ce05339d79af037ec61e1ab785e313fa346d7c
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 17, 2026.

Transparency log

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

Download URL ssh_tunnel_switch-1.1.0-py3-none-any.whl
Size 20.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
64a90697290c9e6f831584b16b20c10ef059f660a14664eeaea7ef50945f2309
BLAKE2b-256 checksum
How to use checksums
cd12acea32f949bc5dc425560f48f4e53c8c4ae753a856c67c1f4daadd3c8867
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 17, 2026.

Transparency log

Security for ssh-tunnel-switch 1.1.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ssh_tunnel_switch-1.1.0.tar.gz

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 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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