Skip to content

Commit 789b221

Browse files
committed
🌐 Improved documantation and added a new argument
BREAKING CHANGES: - Renamed `REMOTE_IP` to `GATEWAY_IP`
1 parent df6d708 commit 789b221

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ ENV SSH_PORT=22
1212
ENV SSH_USER=root
1313
ENV CONTAINER_IP=127.0.0.1
1414
ENV CONTAINER_PORT=80
15-
ENV REMOTE_IP=""
15+
ENV GATEWAY_IP=""
16+
ENV REMOTE_IP="*"
1617
ENV REMOTE_PORT=80
1718

1819
# Security fix for CVE-2016-0777 and CVE-2016-0778

README.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,21 @@
22

33
Create a lightweight Alpine Linux based SSH tunnel to a host. Uses pure SSH, no fluff.
44

5-
For single TCP port applications (database/webserver/debugging access) a SSH tunnel is far faster and simpler than using a VPN like OpenVPN; see this excellent [blog post](https://blog.backslasher.net/ssh-openvpn-tunneling.html) for more info.
5+
**Learn more about ssh tunneling [here](https://iximiuz.com/en/posts/ssh-tunnels/))**
66

7-
For example I use it to create a SSH tunnel from a GCP Kubernetes cluster into an on prem bastion host in order to talk to an on prem MySQL database; it SSHs onto the internal LAN and connects me to the internal on prem MySQL server.
8-
9-
Inspired by https://github.com/iadknet/docker-ssh-client-light and [GCP CloudSQL Proxy](https://cloud.google.com/sql/docs/mysql/sql-proxy)
10-
11-
**FORKED FROM jujhars13/docker-ssh-tunnel/** but reversed the tunnel direction. (more details about tunneling [here](https://iximiuz.com/en/posts/ssh-tunnels/))
7+
FORKED FROM jujhars13/docker-ssh-tunnel but reversed the tunnel direction.
128

139
## Required Parameters
1410

15-
| Variable | Description | Required |
16-
| ------------------ | ----------------------------------------------------------------- | -------- |
17-
| `SSH_PORT` | Port number for SSH (defaults to 22) | No |
18-
| `SSH_USER` | Username for the SSH connection (default: root) | No |
19-
| `CONTAINER_IP` | IP address of the container (default: 127.0.0.1) | No |
20-
| `CONTAINER_PORT` | The port you want to expose on the container (default: 80) | No |
21-
| `REMOTE_IP` | IP/Domain of the machine that will expose your app (the host) | Yes |
22-
| `REMOTE_PORT` | Remote port that will be exposed on the host (default: 80) | No |
11+
| Variable | Description | default |
12+
| ------------------ | ------------------------------------------------------------- | ---------- |
13+
| `SSH_PORT` | Port number for SSH | 22 |
14+
| `SSH_USER` | Username for the SSH connection | root |
15+
| `CONTAINER_IP` | IP address of the container | 127.0.0.1 |
16+
| `CONTAINER_PORT` | The port you want to expose on the container | 80 |
17+
| `GATEWAY_IP` | IP/Domain of the machine that will expose your app (the host) | (required) |
18+
| `REMOTE_PORT` | Which port should sshd listen from on the gateway | 80 |
19+
| `REMOTE_IP` | Which IP should sshd listen from on the gateway (`*` for all) | * |
2320

2421

2522
Note: Remember to inject/mount your private SSH key into the container to `/ssh_key/id_rsa`.

examples/docker-compose.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ services:
1414
- SSH_USER=proxy
1515
- CONTAINER_IP=nginx-hello
1616
- CONTAINER_PORT=80
17-
- REMOTE_IP=openssh-server
17+
- GATEWAY_IP=openssh-server
18+
- REMOTE_IP=*
1819
- REMOTE_PORT=8080
1920

2021
nginx-hello:

run.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,23 @@
66
# ENV SSH_USER=root
77
# ENV CONTAINER_IP=127.0.0.1
88
# ENV CONTAINER_PORT=80
9-
# ENV REMOTE_IP=""
9+
# ENV GATEWAY_IP=""
10+
# ENV REMOTE_IP="*"
1011
# ENV REMOTE_PORT=80
1112

12-
if [ -z ${REMOTE_IP+x} ] ; then
13-
echo "please specify REMOTE_IP;";
13+
if [ -z ${GATEWAY_IP+x} ] ; then
14+
echo "please specify GATEWAY_IP;";
1415
exit 1
1516
fi
1617

17-
echo "starting SSH Reverse proxy $CONTAINER_IP:$CONTAINER_PORT -> $REMOTE_IP:$REMOTE_PORT as $SSH_USER@$REMOTE_IP:$SSH_PORT"
18+
echo "starting SSH Reverse proxy $REMOTE_IP:$REMOTE_PORT -> $CONTAINER_IP:$CONTAINER_PORT as $SSH_USER@$GATEWAY_IP:$SSH_PORT"
1819

1920
/usr/bin/ssh \
2021
-NTC -o ServerAliveInterval=60 \
2122
-o GatewayPorts=yes \
2223
-o ExitOnForwardFailure=yes \
2324
-o StrictHostKeyChecking=no \
24-
-R *:$REMOTE_PORT:$CONTAINER_IP:$CONTAINER_PORT \
25-
$SSH_USER@$REMOTE_IP \
25+
-R $REMOTE_IP:$REMOTE_PORT:$CONTAINER_IP:$CONTAINER_PORT \
26+
$SSH_USER@$GATEWAY_IP \
2627
-p $SSH_PORT \
2728
-i /ssh_key/id_rsa

0 commit comments

Comments
 (0)