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

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.1
File Size Uploaded Provenance Actions
ssh_tunnel_switch-1.1.1.tar.gz 90.2 kB With provenance Details for ssh_tunnel_switch-1.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 111.2 kB

Release files / ssh_tunnel_switch-1.1.1.tar.gz

Download URL ssh_tunnel_switch-1.1.1.tar.gz
Size 90.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0fa64f5ec501636007870a03b8dad25ad4d509a6a01f865a34a7f830e0a5be5a
BLAKE2b-256 checksum
How to use checksums
4986418a72456ba62f48c142430bab41e071debf121a809ce30a9872916586db
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.1-py3-none-any.whl

Download URL ssh_tunnel_switch-1.1.1-py3-none-any.whl
Size 21.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
572b854f59fef40505152de1ea940ede5b813f82b179ad0bf6b7ba0cc8358b50
BLAKE2b-256 checksum
How to use checksums
cea87723e6c86205a418861c7a0ede90f5eaa17d557019ba99776748ead08b18
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.1

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