diff --git a/Dockerfile b/Dockerfile index a2a33d1..c846d61 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,8 @@ RUN set -eux; \ net-tools \ screen \ ; \ - rm -rf /var/lib/apt/lists/* + rm -rf /var/lib/apt/lists/* \ + rm /etc/ssh/ssh_host_*key* ADD start.sh / diff --git a/start.sh b/start.sh index 1e8c195..2f949ec 100755 --- a/start.sh +++ b/start.sh @@ -45,4 +45,11 @@ while [ "$USERADD" != "$i" ] ;do useradd --home-dir "$BASE_DIR/$USER_NAME" --uid "$USER_UID" --gid "$USER_GID" "$USER_NAME" done +if [ -z "$(find /etc/ssh/ -maxdepth 1 -name 'ssh_host_*_key' -print -quit)" ]; then + echo "Creating SSH2 ED25519 key; this may take some time ..." + ssh-keygen -q -f /etc/ssh/ssh_host_ed25519_key -N '' -t ed25519 + ssh-keygen -l -f /etc/ssh/ssh_host_ed25519_key.pub + echo "HostKey /etc/ssh/ssh_host_ed25519_key" >> /etc/ssh/sshd_config +fi + exec /usr/sbin/sshd -D -e