https://github.com/marcelcoding/docker-ssh-tunnel
Docker SSH Tunnel is a pre configured SSH Daemon to tunnel a local port.
https://github.com/marcelcoding/docker-ssh-tunnel
docker ssh tunnel
Last synced: 10 months ago
JSON representation
Docker SSH Tunnel is a pre configured SSH Daemon to tunnel a local port.
- Host: GitHub
- URL: https://github.com/marcelcoding/docker-ssh-tunnel
- Owner: MarcelCoding
- License: agpl-3.0
- Created: 2021-08-19T22:41:36.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-08-08T08:13:49.000Z (over 2 years ago)
- Last Synced: 2025-02-08T04:46:48.748Z (about 1 year ago)
- Topics: docker, ssh, tunnel
- Language: Dockerfile
- Homepage:
- Size: 37.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Docker SSH Tunnel
[](https://github.com/marcelcoding/docker-ssh-tunnel/releases)
Docker SSH Tunnel is a pre configured SSH Daemon to tunnel a local port.
## Usage
1. Deploy, see deployment
2. ```
ssh -N -o ExitOnForwardFailure=yes -o ServerAliveInterval=300 -o ConnectTimeout=5 -g -R 9999:localhost: -p 9714 tunnel@
```
As a scripts witch automatically reconnects you could use something like this:
```bash
#!/bin/sh
while :;
do
echo "Staring SSH tunnel..."
/usr/bin/ssh -N -o ExitOnForwardFailure=yes -o ServerAliveInterval=300 -o ConnectTimeout=5 -g -R 9999:localhost: -p 9714 tunnel@
echo "SSH tunnel has exited. Retry in 10 seconds..."
sleep 10
done
```
## Deployment
This image is available in [Docker Hub](https://hub.docker.com/r/marcelcoding/ssh-tunnel) and the
[GitHub Container Registry](https://github.com/users/MarcelCoding/packages/container/package/ssh-tunnel):
```
marcelcoding/ssh-tunnel:latest
ghcr.io/marcelcoding/ssh-tunnel:latest
```
### Docker "run" Command
```bash
docker run \
-p 9714:22 \
-p 8539:9999 \
-v "${PWD}/keys:/etc/ssh/keys/etc/ssh" \
-v "${PWD}/authorized_keys:/home/tunnel/.ssh/authorized_keys" \
--rm \
marcelcoding/ssh-tunnel:latest
```
### Docker Compose
````yaml
# docker-compose.yaml
version: '3.8'
services:
ssh-tunnel:
restart: always
image: marcelcoding/ssh-tunnel
volumes:
- "./keys:/etc/ssh/keys/etc/ssh" # SSH host keys
- "./authorized_keys:/home/tunnel/.ssh/authorized_keys" # authorized ssh public keys
ports:
- "9714:22" # SSH
- "8539:9999" # forwarded port
````
## License
[LICENSE](LICENSE)