Key is invalid. you must supply a key in openssh public key format

I have followed the “Generating a new SSH key and adding it to the ssh-agent” and tried to follow the “Adding a new SSH key to your GitHub account” documentation. However when I try to add my new SSH key I get the following error: “key is invalid. you must supply a key in openssh public key format.”
I have looked through some of the other discussion threads and am at a loss. My key seems to be in the right format "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIC87cGVRyVxUnw7JaSbgBJi6etAG8lSMQxq3isifGbT$sifGbTb [email]

Any suggestions? Let me know what other details to provide. Thanks!

That format looks correct to me, too. One thing I’d try is to leave of the description (what you abbreviated as “[email]”). If that doesn’t help I’d suspect a bug.

Hi @csperando, welcome to the community
The email at the end of your key is ok as comments are supported for that key type.
All ssh-ed25519 keys will always be 80 (68 removing the ssh-ed25519) characters in length (do not worry about the comment/email at the end).
Anyway on checking you keylength it has an extra 7 characters, which would explain the error message related to an unrecognised key format.

Could you try deleting and regenerating your key, and we can debug from there it f does not work.
ssh-keygen -t ed25519 -C ""
Then try adding your SSH ‘Public’ Key part to your GitHub account (e.g., or replacing id_ed25519 in the command with the name of your private key file you used)

If you are still not working/the key length is incorrect, can you provide some more details on steps to reproduce, such as environment OS, are you using Git and what version, are you using Git Bash or Git CMD?


All ssh-ed25519 keys will always be 80 (68 removing the ssh-ed25519) characters in length

Thank you! Got it to work. Just a simple mistake on my part, like most errors. The terminal was only displaying 79 of the characters, and I miss-copied the key when checking the rest of the line. I did not realize that the ‘$’ character denotes some sort of line break.

1 Like

Please help me I have the same error I am using git bash on window
The same I have added but it is not working

This is the wrong file. You should not see “-----BEGIN OPENSSH PRIVATE KEY-----”, only the characters of the key itself.

What you are looking for is

What @csperando said is correct, but one important addition: You just published your private key. If you already authorized it anywhere (GitHub or otherwise) revoke that now, or anyone can log in as you. :warning:

Generate a new key and then try again with the .pub file. That file contains the public key. :slightly_smiling_face: