{"id":15587974,"url":"https://github.com/david-lor/docker-ssh-port-forward-client","last_synced_at":"2025-04-24T04:50:34.594Z","repository":{"id":47549248,"uuid":"254189803","full_name":"David-Lor/Docker-SSH-Port-Forward-Client","owner":"David-Lor","description":"Dockerized SSH client to forward a remote port to local host 🐳🔐🔌","archived":false,"fork":false,"pushed_at":"2023-01-03T10:22:52.000Z","size":39,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-03-30T07:05:39.067Z","etag":null,"topics":["autossh","docker","port-forwarding","ssh","ssh-server"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/David-Lor.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-08T20:09:44.000Z","updated_at":"2024-07-22T18:11:11.000Z","dependencies_parsed_at":"2023-02-01T05:46:31.726Z","dependency_job_id":null,"html_url":"https://github.com/David-Lor/Docker-SSH-Port-Forward-Client","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/David-Lor%2FDocker-SSH-Port-Forward-Client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/David-Lor%2FDocker-SSH-Port-Forward-Client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/David-Lor%2FDocker-SSH-Port-Forward-Client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/David-Lor%2FDocker-SSH-Port-Forward-Client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/David-Lor","download_url":"https://codeload.github.com/David-Lor/Docker-SSH-Port-Forward-Client/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250566445,"owners_count":21451230,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autossh","docker","port-forwarding","ssh","ssh-server"],"created_at":"2024-10-02T22:20:36.832Z","updated_at":"2025-04-24T04:50:34.564Z","avatar_url":"https://github.com/David-Lor.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker SSH Port Forward Client\n\n[![Docker Hub](https://img.shields.io/badge/%20-DockerHub-blue?logo=docker\u0026style=plastic)](https://hub.docker.com/r/davidlor/ssh-port-forward-client)\n![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/davidlor/ssh-port-forward-client?sort=date\u0026style=plastic)\n\nContainer to connect to a remote SSH server and forward one or more remote TCP ports.\nImage based on python:3-slim-buster, using autossh for SSH connection.\n\n**This image is experimental and might have undesirable effects. Use it under your responsability!**\n\n## Getting started\n\n*Make sure your SSH server is configured properly to allow TCP port forwarding*\n\n- The following example will forward port `80` from remote host to port `8080` on local container, which is finally exposed.\n- The remote host is `192.168.0.100`, with a SSH server available at default port 22 with user `foo`.\n- A SSH private key without password protection is required to connect to the remote server with the given user, and is bind mounted on `/ssh_key` path inside the container.\n\n```bash\ndocker run -d --name=ssh_portforward \\\n  -e \"MAPPINGS=8080:127.0.0.1:80\" \\\n  -e \"SSH_HOST=192.168.0.100\" \\\n  -e \"SSH_USER=foo\" -p 8080:8080 \\\n  -v \"/home/user/ssh_key:/ssh_key:ro\" \\\n  davidlor/ssh-port-forward-client:dev\n```\n\nNow, port 80 of remote host should be accesible from port 8080 within and without the container.\n\n## Configuration\n\nCurrently, the settings are provided through environment variables, which are the following:\n\n### Mappings\n\n**MAPPINGS** is the most important environment variable. Is where we define the relation of local \u0026 remote bind hosts \u0026 ports to forward to and from.\n\nEach mapping must have at least 1 argument and at most 4 arguments, split by `:`. The arguments are: `LOCAL_HOST:LOCAL_PORT:REMOTE_HOST:REMOTE_PORT`, being:\n\n- `REMOTE_PORT`: port on remote machine to forward through SSH (the only argument required)\n- `REMOTE_HOST`: host on remote network to forward the `REMOTE_PORT` from (default: `127.0.0.1` - the SSH server itself, but could be any accessible port from other host from the same network as the SSH server)\n- `LOCAL_PORT`: the remote port will be exposed on this port on the local host -container- (default: the same as `REMOTE_PORT`)\n- `LOCAL_HOST`: where to bind the `LOCAL_PORT` - this can be used to limit access to the port (default: `0.0.0.0` - any host, and since this will be running on a container, it can be limited using Docker port mapping)\n\nMapping examples:\n\n- `80`: forward port 80 from remote host (where SSH server is running) to port 80 of local container\n- `192.168.0.200:80`: forward port 80 from the host 192.168.0.200 (visible by the SSH server) to port 80 of local container\n- `8080:127.0.0.1:80`: forward port 80 from remote host (where SSH server is running) to port 8080 of local container\n- `127.0.0.1:80:127.0.0.1:80`: forward port 80 from remote host (where SSH server is running) to port 80 of local container, and only accesible by the container itself (or by the host, if network=host)\n\nMultiple mappings can be defined by:\n\n- Using a single `MAPPINGS` env var, and splitting them by `;` (when running docker run, the value must be passed between quotes, like `-e MAPPINGS=\"8080:127.0.0.1:80; 4443:127.0.0.1:443\"`). Spaces are ignored.\n- Using multiple environment variables, starting with `MAPPING`. For example, they could be named like \"MAPPING1\", \"MAPPING_1\", \"MAPPING_SSH\", and so on. Inside each env var, one or many mappings can be defined. All of them will be merged and used.\n\n#### Reverse port forwarding\n\nAny mapping that starts with a `R` is considered a reverse port forward. This allows to map a port on the client network to the remote server network.\n\nBy defining the following setting: `-e MAPPINGS=\"R8080:127.0.0.1:80\"`, the port 80 on the client host will be accessible on the port 8080 on the remote SSH server host.\nNotice that you might have to set container network to `host` in order to forward host ports.\n\nReverse and non-reverse mappings can be combined on the same connection, thus, the same container.\n\n### SSH server settings\n\n- `SSH_HOST`: remote host/IP to connect to (required)\n- `SSH_PORT`: SSH port on the remote host (default: `22`)\n- `SSH_USER`: user to connect with on the remote SSH server (required)\n\n### Other settings\n\n- `SSH_COMPRESSION`: set to 1 to enable SSH Compression (default: `0`)\n- `SSH_IPV6`: set to `1` to connect using IPv6 (default: `0` - use IPv4)\n- `SSH_KEY_LOCATION`: where to read SSH key from, inside container (default: `/ssh_key`)\n- `SSH_KEY_WRITE_LOCATION`: the SSH key read from `SSH_KEY_LOCATION` is copied to this path, to ensure the file permissions are correct\n- You can define [autossh Environment settings](https://linux.die.net/man/1/autossh) on the container and they will be used (example: `AUTOSSH_DEBUG` set to `1` to enable verbose debug output for autossh)\n\n## TODO\n\n- Allow SSH keys with password\n- Allow login with password only (no key)\n- Define mappings \u0026 settings through file\n- Update mappings in real time, avoiding downtime\n- Allow proxy tunnel\n- Allow to set autossh reconnection settings\n- Allow to set custom SSH options (for unsupported settings)\n- Allow to provide SSH server public key for host verification\n- Add healthcheck based on forwarded ports\n- Add automated tests\n- Add sshd_config server settings examples\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavid-lor%2Fdocker-ssh-port-forward-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavid-lor%2Fdocker-ssh-port-forward-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavid-lor%2Fdocker-ssh-port-forward-client/lists"}