1
0

feat: generate SSH2 ED25519 HostKey during startup

This commit is contained in:
Pim van den Berg 2022-09-17 14:20:16 +02:00
parent 077eec64ee
commit 726243a733
2 changed files with 9 additions and 1 deletions

View File

@ -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 /

View File

@ -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