[FEATURE] Connect to SSH hosts through a Cloudflare Tunnel hostname
Title
Connect to SSH hosts through a Cloudflare Tunnel hostname
Platform
CLI - macOS
Is it related to an issue?
Yes. Termix can't reach an SSH server that's only exposed through a Cloudflare Tunnel public hostname (an ssh:// route like ssh-a.example.com -> ssh://127.0.0.1:22222 with a proxied CNAME). The connection times out:
Connecting to ssh-a.example.com port 22
Resolved ssh-a.example.com to 172.67.x.x
Using SSH key authentication
Authenticating as <user>
[ERROR] Connection timeout
Connection rejected by server. Please check your authentication and network configuration.
Termix makes a plain TCP connection to Cloudflare's edge on port 22. Cloudflare only accepts HTTP/HTTPS on a proxied hostname, so the connection never reaches the tunnel. The DNS record and tunnel route are fine. ssh -o ProxyCommand='cloudflared access ssh --hostname %h' [email protected] works from a normal OpenSSH client.
An ssh:// tunnel route only works when the client speaks cloudflared's protocol, and Termix has no ProxyCommand, so there's no way to point a host at one today. The status dot has the same problem: the TCP ping to port 22 always fails, so these hosts always show offline.
The Solution
A per-host toggle, "Connect through Cloudflare Tunnel", that does what cloudflared access ssh does without needing the cloudflared binary.
cloudflared opens a WebSocket to https://ws package, so the backend can open wss://
What it should cover:
- Every SSH path (terminal, file manager, host metrics, plugins), by doing it in the shared SSH transport.
- The status check, which should report online only once sshd answers through the tunnel.
- Jump hosts: a tunnel host should work as any hop in a chain. A later hop can be reached by having the previous hop forward to the hostname on 443 and running TLS and the WebSocket over that stream.
- Connection pooling, so a direct connection is never reused for a tunnel host.
- Timeouts, so the tunnel handshake counts against the connection timeout.
The setting can live in the existing ssh_options JSON, so it needs no database migration.
Additional Context
I built and tested this on my fork: https://github.com/pacnpal/Termix/pull/1
It's working against my real Cloudflare Tunnel hosts. It has unit tests for the transport, jump chain, status probe, pool keys and timeout handling, and I ran an end-to-end check against a local WSS-to-sshd bridge. Happy to open a PR against Termix-SSH/Termix if you want it.
Not covered yet:
- Hostnames behind Cloudflare Access. That needs service token fields, which should be stored encrypted, so it's better as a separate change.
- Turning
ProxyCommand cloudflared access sshlines into the toggle during SSH config import.
Moved here from Termix-SSH/Support. Every Termix repo now handles its own issues, so this one lives with the code it is about. Nothing else changes, and the old link still works.
Auto-triage
Request to support connecting to SSH hosts via Cloudflare Tunnel hostnames using WebSocket transport. The maintainer confirmed this feature was added in Plugin-SSH-Terminal 1.0.3.
| Field | Value |
|---|---|
| Type | Feature request |
| Difficulty | 3/5 (Moderate) |
| Priority | High |
This looks like it might be the same as Termix-SSH/Plugin-SSH-Terminal#4. If it is, add any new details there.
A maintainer will take a look. If anything above looks wrong, just say so.
Added in the SSH Terminal plugin 1.0.3 (Termix-SSH/Plugin-SSH-Terminal#20): turn on Cloudflare Tunnel in a host's Terminal tab, optionally with an Access service token, and the session goes through the tunnel hostname over WebSocket.
This shipped in v26.10.2. Update Termix to the latest version to get it. Thanks for the report!