Key is invalid. you must supply a key in openssh public key format #23089
-
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.” Any suggestions? Let me know what other details to provide. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 34 comments 40 replies
-
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. |
Beta Was this translation helpful? Give feedback.
-
csperando:
Hi @csperando, welcome to the community Could you try deleting and regenerating your key, and we can debug from there it f does not work. 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? |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
Please help me I have the same error I am using git bash on window |
Beta Was this translation helpful? Give feedback.
-
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 id_ed25519.pub |
Beta Was this translation helpful? Give feedback.
-
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. Generate a new key and then try again with the |
Beta Was this translation helpful? Give feedback.
-
Inside the .ssh folder, you will find two keys named [id_ed25519 & id_ed25519.pub] The difference between these two key/files is that 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 and is used for enabling 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. |
Beta Was this translation helpful? Give feedback.
-
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:
Do this instead
|
Beta Was this translation helpful? Give feedback.
-
@jcdevilleres Nice invention. I think the reason for the two keys is, the one without the .pub extension is meant for your private/internal use; for enabling or activating the ssh-agent. Then the other with the .pub extension is meant for public use (activation), this is the reason why when one tries to use the private key on GitHub.com it throws an "invalid key" error. Thanks. |
Beta Was this translation helpful? Give feedback.
-
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? |
Beta Was this translation helpful? Give feedback.
-
If your private key is in |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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 id_ed25519.pub file. Do you see both of these files within the ssh directory? |
Beta Was this translation helpful? Give feedback.
-
Not really…how do I get it |
Beta Was this translation helpful? Give feedback.
-
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 “id_ed25519.pub” and “id_ed25519” |
Beta Was this translation helpful? Give feedback.
-
I would recommend you try following the steps exactly detailed in the document link below. |
Beta Was this translation helpful? Give feedback.
-
just coming here to tell you that Github doesn't accept EDDSA keys with 448 bit length (ED448). Changing to Ed25519 (255 bit) fixed this issue for me |
Beta Was this translation helpful? Give feedback.
-
1.Type "cat" followed by Your public key has been saved in "/home/pando-user/.ssh/id_ed25519.pub" (cat /home/pando-user/.ssh/id_ed25519.pub) and click enter |
Beta Was this translation helpful? Give feedback.
-
Hi, I am a bit frustrated here as I am getting this same error and I have followed ever suggestion on this thread and still am not able to get a key that works. The only thing that I can thing of that is different is that I am trying this on a Raspberry Pi. I have no pbcopy nor any clip commands to run. I just copy the key "that includes my email" that is displayed after running ssh-keygen. So could this be an issue with Raspberry Pi? |
Beta Was this translation helpful? Give feedback.
-
You should also check how you copy the public ssh key. When I opened the .pub file with emacs, it added an extra "/" showing that the content continues in the next line unfortunately it gets copied with the key. But when you use vim or nano, it doesn't add the extra slash and it gets the correct ssh key. |
Beta Was this translation helpful? Give feedback.
-
just had the same issue. It was solved by copying ALL that was shown after running "cat ~/.ssh/id_ed25519.pub", ex: Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
In my case it is showing"key is invalid.you must supply a key in OpenSSH public key format." |
Beta Was this translation helpful? Give feedback.
-
I was using ubuntu 20.04 on a new install and got this error after having saved A LOT of keys previously w/no problem. My usual process is: ssh-keygen # accept all of the defaults
head ~/.ssh/id_rsa.pub # then copy the line returned, which should not have line breaks
What Worked ssh-keygen # accept all defaults
cat ~/.ssh/id_rsa.pub # then copy this string and paste in- from the id-rsa begining to the email at the end
Odd, b/c I have used head for years, with no problem. Anyhow, hope this might be helpful to someone as it is a quick fix. |
Beta Was this translation helpful? Give feedback.
-
I was having this issue for a while but I realized my error. I am using Linux for context. First, use this command to : Then, copy everything that is shown as a result. Here is an example: I was just copying the public key data, which was causing my issue. |
Beta Was this translation helpful? Give feedback.
-
It's simple, there is a public key and a private key, the public key is the one you should copy and paste inside of github. |
Beta Was this translation helpful? Give feedback.
-
Use this video tutorial as a guide to successfully do it. https://www.youtube.com/watch?v=c0rfwxrth6s&pp=ygUUc3NoIGtleSBuZXdiaWUgc3RhY2s%3D |
Beta Was this translation helpful? Give feedback.
-
I was copying the key from the .pub file and wasn't working, a solution that worked for me: Open PuTTy Key Generator -> click Load -> select your .pub file -> it should load the public key at the top, and in the correct format that you can paste in GitHub |
Beta Was this translation helpful? Give feedback.
-
It appears that there might be an issue with the formatting or an extra character in your SSH key when adding it to your GitHub account. Let's troubleshoot:
After checking these steps, attempt to add the SSH key again. If the problem continues, please share the exact public key you are trying to add, making sure to remove any sensitive information. This way, I can assist you more effectively. Profile
|
Beta Was this translation helpful? Give feedback.
-
If anyone is having challenges setting up SSH and adding it to the SSH-agent. Here is a video I made to quickly do that. Don't forget to like or comment. Thank you. |
Beta Was this translation helpful? Give feedback.
-
Hi, I experienced this at Laravel Forge. There is an error saying something like "must only be in one line". |
Beta Was this translation helpful? Give feedback.
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.