openssh: Validate keys and regenerate if needed.

Imitate dropbear init.d-script and make sure we
don't end up with corrupt keys.

This can happen if we use a caching filesystem,
like 'ubifs', and the DUT is powered off during
boot-up.

Signed-off-by: Markus Gothe <markus.gothe@genexis.eu>
This commit is contained in:
Markus Gothe
2025-01-15 18:54:29 +01:00
committed by Michael Heimpold
parent 3ac8092a39
commit 69c29a5b26

View File

@@ -12,6 +12,13 @@ start_service() {
do
# check for keys
key=/etc/ssh/ssh_host_${type}_key
[ -f $key ] && {
[ -x /usr/bin/ssh-keygen ] && {
if ! /usr/bin/ssh-keygen -y -f $key > /dev/null 2>&1; then
rm -rf $key
fi
}
}
[ ! -f $key ] && {
# generate missing keys
[ -x /usr/bin/ssh-keygen ] && {