From 56f153db9c87c00ce85d6899b4038b7f0b36eb9c Mon Sep 17 00:00:00 2001 From: "Alex Pooley (@zuedev)" Date: Thu, 7 May 2026 23:43:08 +0100 Subject: Enhance SSH configuration and key management in Docker setup by persisting keys to avoid "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!" issues --- entrypoint.bash | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'entrypoint.bash') diff --git a/entrypoint.bash b/entrypoint.bash index f3cd66f..d2f7167 100644 --- a/entrypoint.bash +++ b/entrypoint.bash @@ -28,6 +28,17 @@ chown -R git:git /repositories echo "Starting cron service..." cron +# Generate SSH host keys into the persistent volume if they don't exist yet. +# This keeps keys stable across container rebuilds. +mkdir -p /run/ssh +chmod 700 /run/ssh +if [ ! -f /run/ssh/ssh_host_ed25519_key ]; then + echo "Generating SSH host keys..." + ssh-keygen -q -N "" -t rsa -b 4096 -f /run/ssh/ssh_host_rsa_key + ssh-keygen -q -N "" -t ecdsa -f /run/ssh/ssh_host_ecdsa_key + ssh-keygen -q -N "" -t ed25519 -f /run/ssh/ssh_host_ed25519_key +fi + # Start the SSH service in the background echo "Starting SSH service..." /usr/sbin/sshd -D -E /var/log/sshd.log & -- cgit v1.2.3