From caf53ef0a223291ae918a59c1759e3b3952355e2 Mon Sep 17 00:00:00 2001 From: John Kirk Date: Fri, 13 Dec 2024 15:19:42 +0100 Subject: [PATCH] dropbear: configure hostkey auto-generation Config option "HostKeyTypes" specifies which hostkeys to auto-generate for dropbear. uci set dropbear.@dropbear[-1].HostKeyTypes='ed25519' Signed-off-by: John Kirk --- .../network/services/dropbear/files/dropbear.init | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/package/network/services/dropbear/files/dropbear.init b/package/network/services/dropbear/files/dropbear.init index 395237f9bc2..c10a657dbb5 100755 --- a/package/network/services/dropbear/files/dropbear.init +++ b/package/network/services/dropbear/files/dropbear.init @@ -80,7 +80,20 @@ hk_config() # $1 - host key file name hk_config__keyfile() { hk_config keyfile "$1" ; } -ktype_all='ed25519 ecdsa rsa' +hk_enabled_ktypes() { + local ktypes ktype values value ret + + ktypes=$($PROG --help 2>&1|awk '/\s+- /{print $2}') + values=$(uci get dropbear.@dropbear[-1].HostKeyTypes 2>/dev/null) + for ktype in $ktypes ; do + for value in $values ; do + [ $value = $ktype ] && ret="${ret}${ret:+ }${ktype}" + done + done + echo ${ret:=$ktypes} +} + +ktype_all=$(hk_enabled_ktypes) hk_generate_as_needed() {