Skip to content

Commit b985547

Browse files
authored
Merge pull request #2 from binlab/add-custom-address-port
Add configuration for custom address and port
2 parents 8fa1e4f + 0bccc4c commit b985547

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM alpine:3.9
1+
FROM alpine:3.11.6
22

33
LABEL maintainer="Mark <mark.binlab@gmail.com>"
44

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ behind a `NAT`. This image based on `Alpine Linux` last version.
4040

4141
* `AGENT_FORWARDING [true | false]` - Specifies whether `ssh-agent` forwarding is permitted. The default is `true`. Note that disabling agent forwarding does not improve security unless users are also denied shell access, as they can always install their own forwarders.
4242

43+
* `LISTEN_ADDRESS [0.0.0.0]` - Specifies the local addresses should listen on. By default it **0.0.0.0**. Useful when Docker container runs in `Host mode`
44+
45+
* `LISTEN_PORT [22]` - Specifies the port number that listens on. The default is **22**. Useful when Docker container runs in `Host mode`
46+
4347
### Run Bastion and `expose` port `22222` to outside a host machine
4448

4549
The container assumes your `authorized_keys` file with `644` permissions and mounted under `/var/lib/bastion/authorized_keys`.

bastion

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@ if [ ! -f "$HOST_KEYS_PATH/ssh_host_rsa_key" ]; then
5454
/usr/bin/ssh-keygen -A -f "$HOST_KEYS_PATH_PREFIX"
5555
fi
5656

57+
if [ -n "$LISTEN_ADDRESS" ]; then
58+
CONFIG_LISTEN_ADDRESS="-o ListenAddress=$LISTEN_ADDRESS"
59+
else
60+
CONFIG_LISTEN_ADDRESS="-o ListenAddress=0.0.0.0"
61+
fi
62+
63+
if [ -n "$LISTEN_PORT" ]; then
64+
CONFIG_LISTEN_PORT="-o Port=$LISTEN_PORT"
65+
else
66+
CONFIG_LISTEN_PORT="-o Port=22"
67+
fi
68+
5769
/usr/sbin/sshd -D -e -4 \
5870
-o "HostKey=$HOST_KEYS_PATH/ssh_host_rsa_key" \
5971
-o "HostKey=$HOST_KEYS_PATH/ssh_host_dsa_key" \
@@ -70,4 +82,6 @@ fi
7082
$CONFIG_AGENT_FORWARDING \
7183
$CONFIG_TCP_FORWARDING \
7284
$CONFIG_TRUSTED_USER_CA_KEYS \
73-
$CONFIG_AUTHORIZED_PRINCIPALS_FILE
85+
$CONFIG_AUTHORIZED_PRINCIPALS_FILE \
86+
$CONFIG_LISTEN_ADDRESS \
87+
$CONFIG_LISTEN_PORT

0 commit comments

Comments
 (0)