Skip to content

Commit

Permalink
Add persistent host keys directory /ssh_host_keys
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinab25 authored Sep 4, 2024
1 parent 79bd7d9 commit 1ebe408
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,23 @@ for item in `env`; do
esac
done

# Generate host SSH keys
if [ ! -e /etc/ssh/ssh_host_rsa_key.pub ]; then

if [ -e /ssh_host_keys/ssh_host_rsa_key.pub ] && [ -e /ssh_host_keys/ssh_host_rsa_key ]; then
# Copy persistent host keys
echo "Using existing SSH host keys"
cp /ssh_host_keys/* /etc/ssh/
elif [ ! -e /etc/ssh/ssh_host_rsa_key.pub ]; then
# Generate host SSH keys
echo "Generating SSH host keys"
ssh-keygen -A
if [ -d /ssh_host_keys ]; then
# Store generated keys on persistent volume
echo "Persisting SSH host keys in /ssh_host_keys"
cp -up /etc/ssh/ssh_host_* /ssh_host_keys/
fi
fi


# Generate root SSH key
if [ ! -e /root/.ssh/id_rsa.pub ]; then
ssh-keygen -q -N "" -f /root/.ssh/id_rsa
Expand Down

0 comments on commit 1ebe408

Please sign in to comment.