Skip to content

Commit

Permalink
openssh: Validate keys and regenerate if needed.
Browse files Browse the repository at this point in the history
Imitate dropbear init.d-script and make sure we
don't end up with corrupt keys.

Signed-off-by: Markus Gothe <[email protected]>
  • Loading branch information
Markus Gothe committed Jan 15, 2025
1 parent d91b062 commit 68288ed
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions net/openssh/files/sshd.init
Original file line number Diff line number Diff line change
Expand Up @@ -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 -l -f $key > /dev/null 2>&1; then
rm -rf $key
fi
}
}
[ ! -f $key ] && {
# generate missing keys
[ -x /usr/bin/ssh-keygen ] && {
Expand Down

0 comments on commit 68288ed

Please sign in to comment.