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 d90c2b1..9063796 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" @@ -115,6 +116,9 @@ if [ ! -f "$userConfFinalPath" ]; then createUser "$user" done < "$userConfFinalPath" + # Generate unique ssh keys for this container + dpkg-reconfigure openssh-server + # Source custom scripts, if any if [ -d /etc/sftp.d ]; then for f in /etc/sftp.d/*; do