Unable to add SSH key

Hi there. Need a bit of direction. Trying to allow for ssh connection via the Balena CLI. documentation doe snot provide how to create key. I have created keys, but get a error stating:

"should match pattern “^(ssh-rsa|ssh-dss|ssh-ed25519|ecdsa-sha2-nistp256|ecdsa-sha2-nistp384|ecdsa-sha2-nistp521) [A-Za-z0-9+/=]+( [^ ]+)*$”

No idea what i’m doing wrong. using Puttykeygen. Could really use a well explained process starting with how to create a key, where to store it locally and then how to add it to the keys under preferences. Thanks.

Hi,

It is expecting your public key in the format used by OpenSSH, rather than PuTTY (SSH2 format).
You should be able to convert it, using ssh-keygen -i -f <ssh2 keyfile>.pub

You may also need to convert your key to OpenSSH (in puttygen: Conversions > Export OpenSSH) before exporting your public key.
I’m not 100% sure balena-cli accepts PuTTY keys. (believe its default behavior is to wrap openssh, which doesn’t)

1 Like

Thanks @TJvV!!! That seems to have worked.

Thanks for the assist @TJvV !

i try to do the same got error: do_convert_from_ssh2: base64 decoding failed: invalid format

Hi,

It sounds to me like you might be trying to convert a wrong type of key.
This is the same error you get when trying to convert a key that’s already in the right format.
Which format does your public key have?

If it already looks something like ssh-rsa single-line-base64-key-string comment, you don’t need to convert it.
Only when it looks like

---- BEGIN SSH2 PUBLIC KEY ----
Comment: "comment"
multi-line
base64-string
here
---- END SSH2 PUBLIC KEY ----

Do you need to convert it.

hmm, I just experienced an issue with ssh rsa keys today. One of my devices is still using that old key but it no longer worked. If I try to delete and re-add the key, it complains about a pattern not matching. I had to update that to ed25519 instead.

Either rsa is no longer supported or there is a bug with the rsa key at the moment.

Hi,

Can you maybe make a new thread for this issue?
Makes it easier to keep track of things that are solved and not.

Done. ssh-rsa keys broke