From 248919721cf9f34675f0b2b572d6d5af327b5036 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Sun, 22 Mar 2020 12:16:35 +0100 Subject: [PATCH] add testing Dockerfile and entrypoint script --- Dockerfile.test | 18 ++++++++++++++++++ test.sh | 12 ++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 Dockerfile.test create mode 100755 test.sh diff --git a/Dockerfile.test b/Dockerfile.test new file mode 100644 index 0000000..6d86374 --- /dev/null +++ b/Dockerfile.test @@ -0,0 +1,18 @@ +FROM alpine + +RUN apk -U add openssh-server openssh-sftp-server sudo python3 +RUN adduser -D user +RUN passwd -u user +RUN passwd -u root +RUN echo "user ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers +RUN echo "PasswordAuthentication no" > /etc/ssh/sshd_config +RUN echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config +RUN echo "AuthorizedKeysFile /etc/ssh/authorized_keys" >> /etc/ssh/sshd_config +RUN echo "PermitRootLogin no" >> /etc/ssh/sshd_config +RUN echo "Subsystem sftp /usr/lib/openssh/sftp-server" >> /etc/ssh/sshd_config + +RUN ssh-keygen -A + +COPY test.sh / + +ENTRYPOINT ["/test.sh"] diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..e63ead0 --- /dev/null +++ b/test.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +key="$SSH_PUBLIC_KEY" + +if test -z "$key"; then + echo "set SSH_PUBLIC_KEY environment variable first" + exit 1 +fi + +echo "$key" > /etc/ssh/authorized_keys + +exec /usr/sbin/sshd -D