From 4c3c0608b4d9843ca6aed0d52f5968c4fd15960f Mon Sep 17 00:00:00 2001 From: Sergey Galuza Date: Thu, 24 Mar 2016 00:32:26 +0300 Subject: [PATCH 1/3] run /etc/sftp.d script each time (even after restarts) --- entrypoint | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/entrypoint b/entrypoint index d90c2b1..d0231a9 100755 --- a/entrypoint +++ b/entrypoint @@ -115,13 +115,13 @@ if [ ! -f "$userConfFinalPath" ]; then createUser "$user" done < "$userConfFinalPath" - # Source custom scripts, if any - if [ -d /etc/sftp.d ]; then - for f in /etc/sftp.d/*; do - [ -x "$f" ] && . "$f" - done - unset f - fi + +fi +# Source custom scripts, if any +if [ -d /etc/sftp.d ]; then + for f in /etc/sftp.d/*; do + [ -x "$f" ] && . "$f" + done + unset f fi - exec /usr/sbin/sshd -D From e521b243f49497e46beac0400fde351a86384126 Mon Sep 17 00:00:00 2001 From: Sergey Galuza Date: Thu, 24 Mar 2016 08:00:48 +0300 Subject: [PATCH 2/3] fixed whitespace --- entrypoint | 2 -- 1 file changed, 2 deletions(-) diff --git a/entrypoint b/entrypoint index d0231a9..0e829c1 100755 --- a/entrypoint +++ b/entrypoint @@ -114,8 +114,6 @@ if [ ! -f "$userConfFinalPath" ]; then while IFS= read -r user || [[ -n "$user" ]]; do createUser "$user" done < "$userConfFinalPath" - - fi # Source custom scripts, if any if [ -d /etc/sftp.d ]; then From 8ffc9c2b6fb3388d4ceb4ee0a57339842769713e Mon Sep 17 00:00:00 2001 From: Adrian Dvergsdal Date: Mon, 28 Mar 2016 18:06:53 +0200 Subject: [PATCH 3/3] Generate unique ssh keys for each container (issue #32) --- Dockerfile | 7 +++++-- entrypoint | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5e97ea5..c8777b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,8 +5,11 @@ RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get -y install openssh-server && \ rm -rf /var/lib/apt/lists/* -# sshd needs this directory to run -RUN mkdir -p /var/run/sshd +# Step 1: sshd needs /var/run/sshd/ to run +# Step 2: Remove keys, they will be generated later by entrypoint +# (unique keys for each container) +RUN mkdir -p /var/run/sshd && \ + rm /etc/ssh/ssh_host_*key* COPY sshd_config /etc/ssh/sshd_config COPY entrypoint / diff --git a/entrypoint b/entrypoint index 0e829c1..10bef10 100755 --- a/entrypoint +++ b/entrypoint @@ -1,5 +1,6 @@ #!/bin/bash set -e +export DEBIAN_FRONTEND=noninteractive userConfPath="/etc/sftp-users.conf" userConfFinalPath="/var/run/sftp-users.conf" @@ -114,7 +115,11 @@ if [ ! -f "$userConfFinalPath" ]; then while IFS= read -r user || [[ -n "$user" ]]; do createUser "$user" done < "$userConfFinalPath" + + # Generate unique ssh keys for this container + dpkg-reconfigure openssh-server fi + # Source custom scripts, if any if [ -d /etc/sftp.d ]; then for f in /etc/sftp.d/*; do @@ -122,4 +127,5 @@ if [ -d /etc/sftp.d ]; then done unset f fi + exec /usr/sbin/sshd -D