Skip to content

Commit 65967c3

Browse files
committed
Add SSH docs
1 parent 9443d56 commit 65967c3

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

README.md

+30-4
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,42 @@ frontend (web browser) <-> server (tunnel-server) <-> backend (tunnel-client)
1010

1111
Download `tunnel-client` wherever you are running the service you want to expose. Let say your service is running on `localhost:8888`. When you run `tunnel-client localhost:8888` it will print a URL you can click on.
1212

13-
Static precompiled binaries (Linux, Mac, Windows) are avaliable under CI/CD.
13+
Static precompiled binaries (Linux, Mac, Windows) are avaliable under CI/CD.
1414

1515
The `-hostname <hostname>` option can be provided to request a specific hostname. However, each hostname is temporarily protected by a secret token. The token doesn't matter when using random URLs, but you should specify `-token <token>` if you want to use the same url multiple times.
1616

17-
## Limitations
17+
### SSH
1818

19-
`tunnel-client` only works with plain text protocols (HTTP). Whatever you expose will be encrypted during all segements of transfer. You technically could expose any TCP port, but it would require a custom frontend which could interpet tls wrapped traffic.
19+
You can use `socat` to unwrap the TLS layer and connect to an SSH server (or any other binary protocol).
20+
21+
Example steps:
22+
23+
1. Start the tunnel client on the server you want to connect to:
24+
```bash
25+
tunnel-client --hostname my-ssh-server.example.invalid localhost:22
26+
```
27+
28+
2. Start socat proxy:
29+
```bash
30+
socat TCP-LISTEN:1234,reuseaddr,fork openssl-connect:my-ssh-server.example.invalid:443
31+
```
32+
33+
3. Connect via SSH:
34+
```bash
35+
ssh localhost:1234
36+
```
37+
38+
You could also use the `ProxyCommand` directive in an `ssh_config`:
39+
40+
```
41+
Host my-ssh-server
42+
HostName my-ssh-server.example.invalid
43+
Port 443
44+
ProxyCommand socat - openssl-connect:%h:%p
45+
```
2046

2147
## Design
2248

2349
TLS Server Name Indication (SNI) is what enables the whole system. Basically when you connect to a TLS server, you indicate which name you are trying to contact in clear text. We can route frontend and backend connections based on what SNI they provide.
2450

25-
When you run `tunnel-client`, it will make a number of preemptive connections to `tunnel-server`. The connections sit idle until a client connects. If the connection is used/disconnected/killed, `tunnel-client` automatically opens additional connections to continually service traffic. Many clients should be able to connect.
51+
When you run `tunnel-client`, it will make a number of preemptive connections to `tunnel-server`. The connections sit idle until a client connects. If the connection is used/disconnected/killed, `tunnel-client` automatically opens additional connections to continually service traffic. Many clients should be able to connect.

cmd/tunnel-client/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ var rootCmd = &cobra.Command{
8585
controlName += ":443"
8686
}
8787
hostnameFqdn := hostname
88-
if !strings.Contains(hostnameFqdn, ".") {
88+
if hostnameFqdn != "" && !strings.Contains(hostnameFqdn, ".") {
8989
hostnameFqdn = strings.Join([]string{hostname, server}, ".")
9090
}
9191

0 commit comments

Comments
 (0)