Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.11.6
FROM alpine:3.12.1

LABEL maintainer="Mark <[email protected]>"

Expand All @@ -20,6 +20,8 @@ RUN addgroup -S -g ${GID} ${GROUP} \
&& sed -i "s/${USER}:!/${USER}:*/g" /etc/shadow \
&& set -x \
&& apk add --no-cache openssh-server \
openssh-server-pam \
linux-pam \
&& echo "Welcome to Bastion!" > /etc/motd \
&& chmod +x /usr/sbin/bastion \
&& mkdir -p ${HOST_KEYS_PATH} \
Expand All @@ -30,4 +32,4 @@ EXPOSE 22/tcp

VOLUME ${HOST_KEYS_PATH}

ENTRYPOINT ["bastion"]
ENTRYPOINT ["bastion"]
10 changes: 9 additions & 1 deletion bastion
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ else
CONFIG_LISTEN_PORT="-o Port=22"
fi

if [ "x$OPEN_ACCESS" = "xtrue" ]; then
echo "Warning: server will accept all incoming connections!!!"
CONFIG_ACCESS="-o UsePAM=yes"
echo "bastion" >/etc/sshd_allowed_users
echo "auth sufficient pam_listfile.so item=user sense=allow file=/etc/sshd_allowed_users onerr=fail" > /etc/pam.d/sshd
fi

/usr/sbin/sshd -D -e -4 \
-o "HostKey=$HOST_KEYS_PATH/ssh_host_rsa_key" \
-o "HostKey=$HOST_KEYS_PATH/ssh_host_dsa_key" \
Expand All @@ -84,4 +91,5 @@ fi
$CONFIG_TRUSTED_USER_CA_KEYS \
$CONFIG_AUTHORIZED_PRINCIPALS_FILE \
$CONFIG_LISTEN_ADDRESS \
$CONFIG_LISTEN_PORT
$CONFIG_LISTEN_PORT \
$CONFIG_ACCESS
9 changes: 9 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

docker build -t bastion .


docker run --rm --name bastion \
-p 2222:22 \
-e OPEN_ACCESS=true \
bastion