ssh/init

33 lines
638 B
Plaintext
Raw Normal View History

2023-07-26 10:56:43 +00:00
#!/bin/sh
2023-07-26 11:19:44 +00:00
set -e
2023-07-26 10:56:43 +00:00
generate_host_key_type() {
local bit_size key_type
key_type=$1
2023-07-26 11:19:44 +00:00
if [ ! -f ${SSH_KEY_PATH}/ssh_host_"${key_type}"_key ]; then
2023-07-26 10:56:43 +00:00
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