same as autossh but with tls support
1.5K
A minimal, production-ready container for establishing reverse SSH tunnels over TLS with SNI routing using autossh.
Perfect for exposing internal services securely when the SSH server is behind a TLS-terminating gateway (e.g., port 443 with SNI-based routing).
š GitHub: https://github.com/NopeNix/autossh-tlsā
š³ Docker Hub: https://hub.docker.com/r/nopenix/autossh-tlsā
š Base Image: alpine:3.18
š License: MIT
autossh if the tunnel drops| Variable | Description | Required |
|---|---|---|
SSH_HOST | Remote SSH server hostname | ā |
SSH_PORT | Remote SSH server port (typically 443) | ā |
SNI_HOST | SNI hostname for TLS routing | ā |
SSH_USER | SSH username for authentication | ā |
SSH_KEY_FILE | Path to private SSH key file | ā |
REMOTE_BIND_PORT | Port to bind on the remote SSH server (reverse) or local port (forward) | ā |
TARGET_HOST | Hostname of the service to tunnel to | ā |
TARGET_PORT | Port of the service to tunnel to | ā |
TUNNEL_DIRECTION | Direction of tunnel (reverse or forward) - defaults to reverse |
services:
autossh-tls:
image: nopenix/autossh-tls:latest
environment:
- SSH_HOST=c.example.com
- SSH_PORT=443
- SNI_HOST=tunnel-mysql.example.com
- SSH_USER=tunnel
- SSH_KEY_FILE=/root/.ssh/id_rsa
- REMOTE_BIND_PORT=3306
- TARGET_HOST=mysql
- TARGET_PORT=3306
# Default is reverse tunnel, but you can be explicit:
- TUNNEL_DIRECTION=reverse
volumes:
- ./ssh:/root/.ssh:ro
restart: unless-stopped
services:
autossh-tls-forward:
image: nopenix/autossh-tls:latest
environment:
- SSH_HOST=c.example.com
- SSH_PORT=443
- SNI_HOST=tunnel-mysql.example.com
- SSH_USER=tunnel
- SSH_KEY_FILE=/root/.ssh/id_rsa
- REMOTE_BIND_PORT=3306 # Local port to bind
- TARGET_HOST=mysql.internal
- TARGET_PORT=3306
- TUNNEL_DIRECTION=forward
volumes:
- ./ssh:/root/.ssh:ro
ports:
- "3306:3306" # Expose the local port
restart: unless-stopped
In reverse tunnel mode, connections to REMOTE_BIND_PORT on the SSH server are forwarded to TARGET_HOST:TARGET_PORT in the docker container's network.
This is useful for exposing internal services to external clients through the SSH server.
In forward tunnel mode, connections to REMOTE_BIND_PORT on the local machine (where the container runs) are forwarded to TARGET_HOST:TARGET_PORT accessible from the SSH server's network.
known_hosts file to prevent MITM attacksTo generate the required known_hosts file:
ssh-keyscan -p $SSH_PORT $SSH_HOST >> known_hosts
Let me know if you'd like the README expanded with more examples, usage notes, or tailored for specific environments like Kubernetes!
Content type
Image
Digest
sha256:b410fbf9eā¦
Size
5.5 MB
Last updated
9 months ago
docker pull nopenix/autossh-tls