Fixing ssh: Exited: String too long on OpenWRT


When trying to execute SSH on OpenWRT with a private key, e.g.

ssh -i id_rsa user@host

you encounter this error:

ssh: Exited: String too long


This error occurs because the ssh executable on OpenWRT is not the same SSH as you would expet on a normal computer:

root@OpenWRT:~# ssh
Dropbear client v2011.54

The DropBear SSH variant expects SSH keys in the DropBear format and not in the PEM format (which is generated by ssh-keygen). In order to generate a new key, use dropbearkey like this:

dropbearkey -f id_rsa -t rsa -b 2048

In order to convert existing keys to the DropBear format, try using dropbearconvert

You can extract the public key from the DropBear key like this:

dropbearkey -y -f id_rsa