openwrt/package/network/services/dropbear/files/dropbear.defaults
John Crispin e428d7999a dropbear: add a uci-defaults script for loading authorized keys
Write the ssh authorized key to /etc/dropbear/ssh_authorized_keys if present
inside boad.json.

Signed-off-by: John Crispin <john@phrozen.org>
2024-10-02 15:41:33 +02:00

21 lines
556 B
Plaintext

[ ! -s /etc/dropbear/authorized_keys ] || exit 0
. /usr/share/libubox/jshn.sh
json_init
json_load "$(cat /etc/board.json)"
json_select credentials
json_get_keys keys ssh_authorized_keys
[ -z "$keys" ] || {
touch /etc/dropbear/authorized_keys
uci set dropbear.@dropbear[-1].PasswordAuth='off'
uci set dropbear.@dropbear[-1].RootPasswordAuth='off'
}
json_select ssh_authorized_keys
for key in $keys; do
json_get_var val "$key"
echo "$val" >> /etc/dropbear/authorized_keys
done
json_select ..
json_select ..