GithubHelp home page GithubHelp logo

sshtunnel's Introduction

sshtunnel

Docker SSH Tunnel

The below example is the same as SSH'ing to host.example.com on port 22, then forwarding port 2525 on the local machine to localhost (which is host.example.com) port 25 using the identity file keyfile. The ports setting is only required if you want to use the tunnel on the host. It is not required for other containers to use the tunnel.

version: '2'

services:

  sshtunnel:
    image: nowsci/sshtunnel
    container_name: sshtunnel
    ports:
      - "2525:2525"
    volumes:
      - ./sshtunnel/data/:/data/:ro
    environment:
      - TUNNEL_HOST=host.example.com
      - TUNNEL_PORT=22
      - REMOTE_HOST=localhost
      - LOCAL_PORT=2525
      - REMOTE_PORT=25
      - KEY=/data/keyfile
      - VERBOSE=true
    restart: always

Or for multiple ports:

version: '2'

services:

  sshtunnel:
    image: nowsci/sshtunnel
    container_name: sshtunnel
    ports:
      - "2525:2525"
    volumes:
      - ./sshtunnel/data/:/data/:ro
    environment:
      - TUNNEL_HOST=host.example.com
      - TUNNEL_PORT=22
      - REMOTE_HOST=localhost,localhost
      - LOCAL_PORT=2525,2526
      - REMOTE_PORT=25,26
      - KEY=/data/keyfile
      - VERBOSE=true
    restart: always

To use the tunnel in reverse mode, allowing a port on a remote server to redirect to a port on a local container, use the following. The below example is the same as SSH'ing to host.example.com on port 22, then forwarding port 8080 on the remote machine to the container nginx (which is on the local machine) with port 80 using the identity file keyfile.

version: '2'

services:

  sshtunnel:
    image: nowsci/sshtunnel
    container_name: sshtunnel
    volumes:
      - ./sshtunnel/data/:/data/:ro
    environment:
      - REMOTE=true
      - TUNNEL_HOST=host.example.com
      - TUNNEL_PORT=22
      - CONTAINER_HOST=nginx
      - CONTAINER_PORT=80
      - REMOTE_PORT=8080
      - KEY=/data/keyfile
      # Optional
      # - LISTEN_HOST=0.0.0.0
      - VERBOSE=true
    restart: always

Or for multiple ports:

version: '2'

services:

  sshtunnel:
    image: nowsci/sshtunnel
    container_name: sshtunnel
    volumes:
      - ./sshtunnel/data/:/data/:ro
    environment:
      - REMOTE=true
      - TUNNEL_HOST=host.example.com
      - TUNNEL_PORT=22
      - CONTAINER_HOST=nginx,nginx
      - CONTAINER_PORT=80,443
      - REMOTE_PORT=8080,4043
      - KEY=/data/keyfile
      # Optional
      # - LISTEN_HOST=0.0.0.0
      - VERBOSE=true
    restart: always

sshtunnel's People

Contributors

fmstrat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.