Skip to content

Commit 99bfca3

Browse files
authored
Merge pull request #18 from Dobli/openssh-server-ssh-tunnel
Added mod for ssh tunneling
2 parents ca2c0ce + 73f038d commit 99bfca3

File tree

6 files changed

+41
-66
lines changed

6 files changed

+41
-66
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ language: shell
44

55
branches:
66
only:
7-
- <baseimagename>-<modname> #replace variables, omit brackets
7+
- openssh-server-ssh-tunnel
88

99
services:
1010
- docker
1111

1212
env:
1313
global:
14-
- DOCKERHUB="linuxserver/mods" #don't modify
15-
- BASEIMAGE="baseimagename" #replace
16-
- MODNAME="modname" #replace
14+
- DOCKERHUB="linuxserver/mods"
15+
- BASEIMAGE="openssh-server"
16+
- MODNAME="ssh-tunnel"
1717

1818
jobs:
1919
include:
@@ -32,4 +32,4 @@ jobs:
3232
- echo $DOCKERPASS | docker login -u $DOCKERUSER --password-stdin
3333
# Push all of the tags
3434
- docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT}
35-
- docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}
35+
- docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}

Dockerfile.complex

Lines changed: 0 additions & 21 deletions
This file was deleted.

README.md

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,35 @@
11
# Docker mod for openssh-server
22

3-
This mod adds rsync to openssh-server, to be installed/updated during container start.
3+
This mod adds ssh tunnelling to openssh-server, by enabling tcp forwarding during container start.
44

5-
In openssh-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:openssh-server-rsync`
5+
In openssh-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:openssh-server-ssh-tunnel`
66

7-
# Mod creation instructions
7+
If adding multiple mods, enter them in an array separated by `|`, such as `DOCKER_MODS=linuxserver/mods:openssh-server-ssh-tunnel|linuxserver/mods:openssh-server-mod2`
88

9-
* Ask the team to create a new branch named `<baseimagename>-<modname>`. Baseimage should be the name of the image the mod will be applied to. The new branch will be based on the `template` branch.
10-
* Fork the repo, checkout the template branch.
11-
* Edit the `Dockerfile` for the mod. `Dockerfile.complex` is only an example and included for reference; it should be deleted when done.
12-
* Inspect the `root` folder contents. Edit, add and remove as necessary.
13-
* Edit this readme with pertinent info, delete thse instructions.
14-
* Finally edit the `travis.yml`. Customize the build branch,and the vars for `BASEIMAGE` and `MODNAME`
15-
* Submit PR against the branch created by the team
9+
Note: `GatewayPorts` is set to `clientspecified`, this moves the responsibility to define the gateway host of the port to the client that opens the tunnel, e.g. `*:8080` to forward 8080 to all connection, default is localhost only.
10+
In addition it is still necessary to expose the same port on the container level, using either the `--expose` (only to other containers) or the `--port` (expose on host level/internet) run options (or the counterparts in docker-compose).
11+
12+
Example:
13+
14+
When creating the container with the following setup:
15+
```
16+
version: '2'
17+
services:
18+
openssh-server:
19+
image: linuxserver/openssh-server
20+
environment:
21+
- DOCKER_MODS=linuxserver/mods:openssh-server-ssh-tunnel
22+
volumes:
23+
- /path/to/appdata/config:/config
24+
expose:
25+
- 30000
26+
ports:
27+
- 2222:2222
28+
```
29+
30+
It's possible to expose the client's port 8080 through the container's port 30000 like this:
31+
```
32+
ssh -R *:30000:localhost:8080 example.com -p 2222
33+
```
34+
35+
Port 30000 will then only be available to other containers (e.g. a web server acting as a reverse proxy). When using `ports` instead of `expose` the port would be accessible from the host (and the network it resides in, e.g. the internet). The client command can be automated using autossh.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/with-contenv bash
2+
3+
# allow tcp forwarding within openssh settings
4+
sed -i '/^AllowTcpForwarding/c\AllowTcpForwarding yes' /etc/ssh/sshd_config
5+
sed -i '/^GatewayPorts/c\GatewayPorts clientspecified' /etc/ssh/sshd_config
6+
echo "TcpForwarding is enabled"

root/etc/cont-init.d/99-vpn-config

Lines changed: 0 additions & 27 deletions
This file was deleted.

root/etc/services.d/sshvpn/run

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)