Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarlovi committed Jun 3, 2021
0 parents commit 0f492e6
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM alpine:3.13

RUN apk add --no-cache --update openssh-client
CMD ssh \
-o StrictHostKeyChecking=no \
-N ${TUNNEL_HOST} \
-L ${FORWARD_DSN}

36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# SSH tunnel in Docker

Use case: allow your Docker containers to use SSH tunnels
to get into those hard to reach places like corporate resources,
firewalled APIs etc.

## Usage with Docker Compose

```yaml
services:
# your reglar services

ssh-tunnel:
image: sigwinhq/ssh-tunnel:latest
environment:
# if the key is password-protected
SSH_AUTH_SOCK: "/ssh-agent"
# the host via which we tunnel
TUNNEL_HOST: "[email protected]"
# what do we want to proxy to?
FORWARD_DSN: "*:443:firewalled-api.example.com:443"
volumes:
# your key is now usable by the tunnel
- $HOME/.ssh:/root/ssh:ro
# if the key is password-protected
- $SSH_AUTH_SOCK:/ssh-agent
# this part is to make the tunnel transparent to others
networks:
default:
aliases:
- firewalled-api.example.com
```
After doing this, your other services should now have access
to the firewalled API as if it's available directly,
without even knowing about the proxy.

0 comments on commit 0f492e6

Please sign in to comment.