@@ -1,188 +1,47 @@
|
||||
# sish-client
|
||||
|
||||
A small, environment-driven connector for a [sish](https://github.com/antoniomika/sish) edge.
|
||||
It opens SSH reverse tunnels to the edge, claims hostnames there, and relays their traffic to
|
||||
local targets. In the default mode sish routes by **SNI without terminating TLS**, and each
|
||||
connection starts with a **PROXY v2 header** carrying the real client address.
|
||||
|
||||
```
|
||||
client ──TLS──▶ edge :443 (sish, SNI routing) ══ssh══▶ sish-client ──▶ target (terminates TLS)
|
||||
```
|
||||
|
||||
Image: `registry.traberph.de/public/sish-client` (Alpine + OpenSSH client + tini, ~20 MB,
|
||||
runs as `nobody`, works with a read-only root filesystem).
|
||||
|
||||
## Quick start
|
||||
Opens SSH reverse tunnels to a [sish](https://github.com/antoniomika/sish) edge and reconnects
|
||||
every 5s when the session drops. Image: `registry.traberph.de/public/sish-client`.
|
||||
|
||||
```sh
|
||||
docker run -d --name sish-client --read-only --tmpfs /tmp \
|
||||
docker run -d --read-only --tmpfs /tmp \
|
||||
-e SISH_HOST=edge.example.com \
|
||||
-e SISH_HOST_KEY="ssh-ed25519 AAAA..." \
|
||||
-e ROUTES="app.example.com=app:8443" \
|
||||
-e SISH_ROUTES="app.example.com:443=app:8443" \
|
||||
-v ./id_ed25519:/secrets/id_ed25519:ro \
|
||||
registry.traberph.de/public/sish-client:latest
|
||||
```
|
||||
|
||||
The connector's **public** key must be authorized on the edge (sish `--authentication-keys-directory`),
|
||||
and each hostname must be allowed there (sish `--bind-hosts` or `_sish` TXT records).
|
||||
|
||||
## Configuration
|
||||
|
||||
| Variable | Default | Description |
|
||||
| Variable | Default | |
|
||||
|---|---|---|
|
||||
| `SISH_HOST` | *required* | Edge hostname or IP |
|
||||
| `SISH_HOST` | *required* | Edge host |
|
||||
| `SISH_HOST_KEY` | *required* | Edge host key, `"<type> <base64>"` (first two fields of its `.pub` file) |
|
||||
| `SISH_ROUTES` | *required* | Comma-separated `host:bind-port=target:port` |
|
||||
| `SISH_PORT` | `2222` | sish SSH port |
|
||||
| `SISH_USER` | `connector` | SSH user (sish accepts any; shows up in edge logs) |
|
||||
| `SISH_KEY` | | Private key contents (e.g. from a Kubernetes `secretKeyRef`). Takes precedence over `SISH_KEY_FILE` |
|
||||
| `SISH_KEY_FILE` | `/secrets/id_ed25519` | Path to a mounted private key |
|
||||
| `SISH_HOST_KEY` | | Edge host public key, `"<type> <base64>"` (the first two fields of the `.pub` file) |
|
||||
| `SISH_KNOWN_HOSTS_FILE` | | Alternative to `SISH_HOST_KEY`: a known_hosts file matching `[SISH_HOST]:SISH_PORT` |
|
||||
| `SISH_STRICT_HOST_KEY` | `true` | `false` disables host key verification (testing only) |
|
||||
| `ROUTES` | | Routes, separated by commas, spaces or newlines (see below) |
|
||||
| `ROUTES_FILE` | | File with routes, one per line, `#` comments allowed. Combined with `ROUTES` |
|
||||
| `TARGET` | | Default `host:port` for routes without an explicit target |
|
||||
| `DEFAULT_BIND_PORT` | `443` | Edge port for routes without an explicit bind port |
|
||||
| `SNI_PROXY` | `true` | Ask sish to route by SNI instead of terminating TLS |
|
||||
| `PROXY_PROTOCOL` | `2` | PROXY header version sent to the target: `1`, `2` or `off` |
|
||||
| `KEEPALIVE_INTERVAL` | `15` | Seconds between SSH keepalives (3 missed = reconnect) |
|
||||
| `CONNECT_TIMEOUT` | `10` | SSH connect timeout in seconds |
|
||||
| `BACKOFF_MIN` / `BACKOFF_MAX` | `2` / `60` | Reconnect backoff in seconds (doubles per failure, resets after a successful session) |
|
||||
| `SSH_EXTRA_OPTS` | | Extra `ssh` arguments, e.g. `-o Ciphers=aes128-gcm@openssh.com` |
|
||||
| `STATE_DIR` | `/tmp/sish-client` | Writable directory for the key copy, known_hosts and the ready marker |
|
||||
| `SISH_KEY_FILE` | `/secrets/id_ed25519` | Private key |
|
||||
| `SISH_SNI_PROXY` | `true` | `true`: sish routes by SNI and passes TLS through. `false`: HTTP routing by `Host` header |
|
||||
| `SISH_PROXY_PROTOCOL` | `2` | PROXY header sent to the target: `1`, `2` or `off` |
|
||||
|
||||
### Routes
|
||||
HTTP (:80) routes need `SISH_SNI_PROXY=false` and a separate instance from SNI (:443) routes.
|
||||
If sish rejects any route, the session fails and is retried, so a bad route shows up in the logs.
|
||||
|
||||
```
|
||||
<host>[:<bind-port>][=<target-host>:<target-port>]
|
||||
```
|
||||
## Requirements
|
||||
|
||||
| Example | Meaning |
|
||||
|---|---|
|
||||
| `app.example.com=traefik:8443` | SNI `app.example.com` on edge :443 → `traefik:8443` |
|
||||
| `app.example.com` | Same, using `TARGET` |
|
||||
| `*.apps.example.com=traefik:8443` | Wildcard (sish needs `--bind-wildcards`) |
|
||||
| `app.example.com:80=traefik:8080` | Plain HTTP on edge :80, routed by `Host` header (**needs `SNI_PROXY=false`**, see below) |
|
||||
- `/tmp` must be writable (e.g. a memory `emptyDir`), the root filesystem can be read-only.
|
||||
- Run as uid `65534` (the image default). ssh refuses to start for uids missing from `/etc/passwd`.
|
||||
- The key file must be readable by uid 65534, e.g. a Secret volume with `defaultMode: 0440`
|
||||
and `fsGroup: 65534`. ssh rejects keys owned by 65534 that others can read.
|
||||
|
||||
**HTTP (:80) and SNI (:443) routes cannot share one connector.** With `SNI_PROXY=true` sish
|
||||
treats every forward as an SNI listener, which collides with its HTTP listener on :80. Run a
|
||||
second instance for HTTP routes (e.g. for HTTP→HTTPS redirects):
|
||||
## Security
|
||||
|
||||
```sh
|
||||
SNI_PROXY=false PROXY_PROTOCOL=off ROUTES="app.example.com:80=traefik:8080"
|
||||
```
|
||||
|
||||
If the edge rejects any route, the whole session fails (`ExitOnForwardFailure`) and is retried
|
||||
with backoff. A misconfigured route is therefore loud (visible in the logs and health status)
|
||||
instead of silently missing.
|
||||
|
||||
Several connectors may claim the same hostname. sish then load-balances between them, which is
|
||||
how you get redundancy (e.g. one connector per ingress replica).
|
||||
|
||||
## Health
|
||||
|
||||
The container writes `$STATE_DIR/ready` once sish has confirmed **every** route, and removes it
|
||||
when the tunnel drops. The image's `HEALTHCHECK` tests this file; in Kubernetes use it as a
|
||||
readiness probe:
|
||||
|
||||
```yaml
|
||||
readinessProbe:
|
||||
exec:
|
||||
command: ["test", "-f", "/tmp/sish-client/ready"]
|
||||
periodSeconds: 5
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Docker Compose
|
||||
|
||||
```yaml
|
||||
services:
|
||||
app:
|
||||
image: nginx # must terminate TLS and accept PROXY protocol on 8443
|
||||
connector:
|
||||
image: registry.traberph.de/public/sish-client:latest
|
||||
read_only: true
|
||||
tmpfs: [/tmp]
|
||||
cap_drop: [ALL]
|
||||
security_opt: [no-new-privileges:true]
|
||||
environment:
|
||||
SISH_HOST: edge.example.com
|
||||
SISH_HOST_KEY: ssh-ed25519 AAAA...
|
||||
ROUTES: app.example.com=app:8443
|
||||
volumes:
|
||||
- ./id_ed25519:/secrets/id_ed25519:ro
|
||||
restart: unless-stopped
|
||||
```
|
||||
|
||||
The key file must be readable by uid `65534` inside the container. Compose ignores `uid`/`mode`
|
||||
on file secrets, so either:
|
||||
- make the key readable by a group and run with `user: "65534:<gid>"`. With **rootless** Docker
|
||||
your host files appear as owned by root inside the container, so the gid is `0`.
|
||||
- or pass the key via `SISH_KEY` instead of a file.
|
||||
|
||||
### Kubernetes sidecar (next to an ingress controller)
|
||||
|
||||
```yaml
|
||||
- name: sish-client
|
||||
image: registry.traberph.de/public/sish-client:20260926154233-1a2b3c4 # {"$imagepolicy": "flux-system:sish-client"}
|
||||
env:
|
||||
- { name: SISH_HOST, value: edge.example.com }
|
||||
- { name: SISH_HOST_KEY, value: "ssh-ed25519 AAAA..." }
|
||||
- { name: ROUTES_FILE, value: /etc/sish-client/routes.txt }
|
||||
- { name: TARGET, value: "127.0.0.1:9443" } # ingress entrypoint with PROXY protocol
|
||||
- name: SISH_KEY
|
||||
valueFrom: { secretKeyRef: { name: sish-client, key: id_ed25519 } }
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
readOnlyRootFilesystem: true
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities: { drop: [ALL] }
|
||||
volumeMounts:
|
||||
- { name: tmp, mountPath: /tmp }
|
||||
- { name: routes, mountPath: /etc/sish-client, readOnly: true }
|
||||
readinessProbe:
|
||||
exec: { command: ["test", "-f", "/tmp/sish-client/ready"] }
|
||||
```
|
||||
|
||||
Routes are only read at connect time. Roll the pods after changing them (e.g. with a config
|
||||
hash annotation).
|
||||
|
||||
## Image tags
|
||||
|
||||
The Gitea workflow (`.gitea/workflows/build.yaml`) builds `linux/amd64` and `linux/arm64` and pushes:
|
||||
|
||||
| Trigger | Tags |
|
||||
|---|---|
|
||||
| Push to `main` | `<yyyymmddHHMMSS>-<sha7>` (UTC) and `latest` |
|
||||
| Git tag `v*` | `<yyyymmddHHMMSS>-<sha7>` and the git tag, e.g. `v1.0.0` |
|
||||
|
||||
Repository secrets required: `REGISTRY_USERNAME`, `REGISTRY_TOKEN` (a token with push access
|
||||
to `registry.traberph.de/public`). The runner needs Docker (Buildx + QEMU for arm64).
|
||||
|
||||
### Flux image automation
|
||||
|
||||
```yaml
|
||||
apiVersion: image.toolkit.fluxcd.io/v1
|
||||
kind: ImageRepository
|
||||
metadata: { name: sish-client, namespace: flux-system }
|
||||
spec:
|
||||
image: registry.traberph.de/public/sish-client
|
||||
interval: 10m
|
||||
---
|
||||
apiVersion: image.toolkit.fluxcd.io/v1
|
||||
kind: ImagePolicy
|
||||
metadata: { name: sish-client, namespace: flux-system }
|
||||
spec:
|
||||
imageRepositoryRef: { name: sish-client }
|
||||
filterTags:
|
||||
pattern: '^(?P<ts>[0-9]{14})-[0-9a-f]{7}$'
|
||||
extract: '$ts'
|
||||
policy:
|
||||
numerical: { order: asc }
|
||||
```
|
||||
|
||||
## Build locally
|
||||
|
||||
```sh
|
||||
docker build -t registry.traberph.de/public/sish-client:dev .
|
||||
```
|
||||
- The edge is authenticated only by `SISH_HOST_KEY`. There is no trust-on-first-use and no
|
||||
fallback: a wrong or missing key fails the connection.
|
||||
- All ssh_config files are ignored (`-F /dev/null`). Agent and X11 forwarding are off, so the
|
||||
edge can only open connections to the configured route targets.
|
||||
- **PROXY protocol:** the target trusts the PROXY header for the client IP. It must only accept
|
||||
PROXY connections from this client (e.g. listen on `127.0.0.1` in the sidecar and set trusted
|
||||
IPs), otherwise anything that can reach that port can spoof client IPs. If the target does not
|
||||
expect a PROXY header, set `SISH_PROXY_PROTOCOL=off`.
|
||||
- Whoever controls the edge sees HTTP traffic, and with `SISH_SNI_PROXY=true` still sees the
|
||||
SNI hostnames and client IPs, but not TLS contents.
|
||||
- The base image follows `alpine:3`. Rebuild regularly to pick up OpenSSH fixes.
|
||||
|
||||
Reference in New Issue
Block a user