ssh/init

33 lines
638 B
Bash
Executable File

#!/bin/sh
set -e
generate_host_key_type() {
local bit_size key_type
key_type=$1
if [ ! -f ${SSH_KEY_PATH}/ssh_host_"${key_type}"_key ]; then
case $key_type in
ecdsa) bit_size="$ecdsa_bit_size";;
rsa) bit_size="$rsa_bit_size";;
esac
ssh-keygen \
-q \
-f ${SSH_KEY_PATH}/ssh_host_"$key_type"_key \
-N '' \
-t "$key_type" \
${bit_size:+ -b ${bit_size}} || return 1
fi
}
for type in ${key_types_to_generate:-dsa ecdsa ed25519 rsa}; do
generate_host_key_type "$type" || return 1
done
/usr/sbin/sshd -e
# Sleep,enabling our SIGTERM to shut us down gracefully
(while true; do sleep 3600; done) &
wait