Containers that create SSH tunnels to various services, to be used with a bastion ssh server.
  • Dockerfile 100%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2021-02-22 09:08:45 +01:00
.github/workflows Update build process. Build weekly on tuesdays. 2021-02-22 09:08:45 +01:00
.gitignore initial release 2019-11-26 14:35:14 +01:00
.hadolint.yaml Hadolinter 2019-11-26 14:37:34 +01:00
Dockerfile Hadolinter 2019-11-26 14:37:34 +01:00
LICENSE Initial commit 2019-11-26 14:22:27 +01:00
README.md Service tunnels name 2019-11-26 14:36:00 +01:00

Docker Service Tunnels

Containers that create SSH tunnels to various services, to be used with a bastion ssh server.

Based on the work of Cagatay Gurturk: https://github.com/cagataygurturk/docker-ssh-tunnel

The major differences are that the tunnel:mysql and tunnel:redis images have healthchecks for the connection.

Usage:

First, make sure your bastion ssh server is configured correctly in your ~/.ssh/config:

Host bastion # You can use any name
    HostName bastion.example.com 
    IdentityFile ~/.ssh/id_rsa # Private key location
    User YourName # Username to connect to SSH service
    ForwardAgent yes
    TCPKeepAlive yes
    ConnectTimeout 5
    ServerAliveCountMax 10
    ServerAliveInterval 15

Its probably a good idea to check that you can use this new connection: ssh bastion

Then we can configure our docker-compose.yml:

  mysql:
    image: matthewbaggett/tunnel:mysql
    volumes:
      - $HOME/.ssh:/root/ssh:ro
    environment:
      TUNNEL_HOST: bastion
      REMOTE_HOST: mysql.example.com
      LOCAL_PORT: 3306
      REMOTE_PORT: 3306
      MYSQL_USER: username
      MYSQL_PASSWORD: changeme
    ports:
      - '3306:3306'

  redis:
    image: matthewbaggett/tunnel:redis
    volumes:
      - $HOME/.ssh:/root/ssh:ro
    environment:
      TUNNEL_HOST: bastion
      REMOTE_HOST: redis.example.com
      LOCAL_PORT: 6379
      REMOTE_PORT: 6379
    ports:
      - '6379:6379'