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:


Inside the .ssh folder, you will find two keys named [id_ed25519 &] The difference between these two key/files is, one is a private key-id and the other is a public key-id, you can notice that from their naming. The key ending with no extension is your private key -id use to enable the ssh-agent internally on your local machine or server while the other ending with .pub is your public key-id, while using the cat/less command to view it you will notice your Github email is added toward the ending part of the key contents this is the one you will use to add as an ssh key to your Github account through the GUI. Thanks.


Hi All

Following this guide today and came across this error. I found the solution as suggested in the previos posts. Instead of following the guide, by doing:

clip < ~/.ssh/id_ed25519

Do this instead

clip < ~/.ssh/


@jcdevilleres Nice invent. I think the reason for the two keys is, the one without the .pub extension is meant for your private use. I.e if you want to activate on your machine internally. Then the one with .pub extension is meant for public use (activation), this is the reason why when one tries to use the private key for GitHub account activation on it’s never accepted. Thanks.

Hi All- How do I find my key? i.e. i created a key in my terminal and it is a .ssh/id_ed25519; but where do I find the 68 digit key? I see something called key fingerprint which starts SHA256 and ends with my email. would this be the key? if so, whats the format to enter?

If your private key is in .ssh/id_ed25519, the matching public key should be in .ssh/ The fingerprint is different, it’s just a hash to identify the key, not the key itself.

Hello, for me I have been unable to add the sshkey, I have tried as everyone has stated but it is not working. My ssh key is ssh/id_ed25519 . I have tried placing it with pub as stated but still it is invalid. How do i get the 68 digit.

id_ed25519 is the name of the file for your private key, not the key itself. The public key should be an 80 characters within the file. Do you see both of these files within the ssh directory?

Not really…how do I get it

First make sure you are in the correct directory “/.ssh” for me this was in “/home/pi/.ssh”. Once there, list the directory structure. For unix the command is “ls” for windows it is “dir”. You should see two files listed “” and “id_ed25519”