Restrict authorized SSH keys in dropbear

I would like to use SSH key restrictions, such as no-port-forwarding or command=, which are supported by dropbear [1]. The use case is per-ssh-key restrictions, as opposed to dropbear-wide restrictions using the corresponding UCI options, in this exemplary case LocalPortForward and ForceCommand (which do not seem to be documented in the OpenWRT wiki [2] yet, but do in fact work).

When adding the restrictions to the file /etc/dropbear/authorized_keys, however, either dropbear or some other component in OpenWRT seems to filter these keys out. Example format of a restricted key: ssh-ed25519 no-port-forwarding <pubkey>. The logs do not show any obvious complaints from any component and I cannot find any reference to a filter in the dropbear service file [3] nor the OpenWRT-specific dropbear patches [4].

I am aware that there is a dedicated OpenSSH server package, but I would like to keep it to a minimal dropbear installation if at all possible.

Is there a way to add restrictions to SSH public keys using OpenWrt’s bundled dropbear, as documented in the dropbear man-page [1]?

Hardware & Software

  • Netgear Nighthawk X4S R7800
  • OpenWrt 24.10.2 r28739-d9340319c6 / LuCI openwrt-24.10 branch 26.003.60801~8770139
  • dropbear 2024.86-r1

Dropbear configuration:

$ uci show dropbear
dropbear.main=dropbear
dropbear.main.PasswordAuth='on'
dropbear.main.Port='56421'

References

I added no-port-forwarding to the front of an existing key and it worked fine.

no-port-forwarding ssh-ed25519 AAAAC3NzaC1…
Tue Jan  6 07:13:39 2026 authpriv.info dropbear[19352]: Child connection from 192.168.1.196:53181
Tue Jan  6 07:13:39 2026 authpriv.warn dropbear[19352]: Port forwarding disabled.
Tue Jan  6 07:13:39 2026 authpriv.warn dropbear[19352]: Port forwarding disabled.
Tue Jan  6 07:13:39 2026 authpriv.notice dropbear[19352]: Pubkey auth succeeded for 'root' with ssh-ed25519 key SHA256:rkgaYAW0eIYb… from 192.168.1.196:53181
4 Likes

Well that's embarrassing. Thank you for the hint, I misread the format. Putting these restrictions in front of the key type indicator totally works. Thanks!

1 Like