Hardened, lightweight Alpine Linux-based SSH tunnel server
258
Hardened, lightweight (~18MB) Alpine Linux-based SSH tunnel server designed exclusively for secure port-forwarding bastions into clusters and private networks.
nologin-tunnel).-N — holding sessions open cleanly until disconnected.-L) and Dynamic SOCKS (-D) forwarding only; reverse forwarding (-R) is disabled.SSH_PERMIT_OPEN.linux/amd64 and linux/arm64.docker run -d \
--name ssh-tunnel \
--restart unless-stopped \
-p 2222:2222 \
-e ALLOWED_IPS="AllowUsers tunnel@*" \
-e AUTHORIZED_KEYS="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5... user@client" \
ays57/ssh-tunnels-server:latest
services:
ssh-tunnel:
image: ays57/ssh-tunnels-server:latest
container_name: ssh-tunnel
restart: unless-stopped
ports:
- "2222:2222"
environment:
- ALLOWED_IPS=AllowUsers tunnel@*
- AUTHORIZED_KEYS=ssh-ed25519 AAAAC3NzaC1lZDI1NTE5... user@client
- SSH_PERMIT_OPEN=database:3306 redis:6379 # Optional: limit tunnel targets
volumes:
- ./ssh_host_keys:/etc/ssh/ssh_host_keys # Optional: persist host keys
-L)Forward local port 3306 through the tunnel to internal service database:3306:
ssh -p 2222 -L 3306:database:3306 tunnel@<server-ip>
(Optionally append -N to skip holding session output)
-D)Route browser or tool traffic through your private network:
ssh -p 2222 -D 1080 tunnel@<server-ip>
| Variable | Default | Description |
|---|---|---|
ALLOWED_IPS | Required | OpenSSH AllowUsers directive (e.g. AllowUsers tunnel@* or AllowUsers [email protected].*) |
AUTHORIZED_KEYS | Required* | Public SSH key string (e.g. ssh-ed25519 ...) |
SSH_USER | tunnel | Non-root SSH username |
SSH_PORT | 2222 | Listening SSH port inside container |
SSH_PERMIT_OPEN | (all) | Space/comma-delimited allowed destinations (e.g. db:5432 internal:80) |
SSH_BANNER | "Connected..." | Pre-auth banner text displayed upon connection (none to disable) |
PUID / PGID | 9999 / 9999 | User ID and Group ID for the SSH tunnel user |
DEBUG | false | Set to true to enable verbose SSHD debugging logs |
* Alternatively, mount your keys to /authorized_keys or /home/tunnel/.ssh/authorized_keys.
For complete documentation, security benchmarks, and advanced configuration, visit the GitHub Repository.
Content type
Image
Digest
sha256:8dd03d1d8…
Size
7 MB
Last updated
19 days ago
docker pull ays57/ssh-tunnels-server