Skip to content

Use SSH tunnelling (AKA port forwarding) within your Docker environment to allow your containers to access remote firewalled services by accessing them via known public IPs.

Notifications You must be signed in to change notification settings

sigwinhq/docker-ssh-tunnel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

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

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.

About

Use SSH tunnelling (AKA port forwarding) within your Docker environment to allow your containers to access remote firewalled services by accessing them via known public IPs.

Topics

Resources

Stars

Watchers

Forks