Fixing ssh: Exited: String too long on OpenWRT

Problem

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

example_ssh_cmd.sh
ssh -i id_rsa user@host

you encounter this error:

error_output.txt
ssh: Exited: String too long

Solution

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

dropbear_version.sh
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:

generate_dropbear_key.sh
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:

extract_pubkey.sh
dropbearkey -y -f id_rsa

Check out similar posts by category: Embedded, Linux