Skip to content

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

Key is invalid. you must supply a key in openssh public key format #23089
Mar 23, 2021 · 19 answers · 7 replies

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!

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.

Replies

19 suggested answers
·
7 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.

0 replies
csperando:

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.”

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 "your_email@example.com"
Then try adding your SSH ‘Public’ Key part to your GitHub account (e.g. id_ed25519.pub, 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?

0 replies

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.

0 replies
Answer selected

Please help me I have the same error I am using git bash on window
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
QyNTUxOQAAACCO4k4/VekVHrQZxeRzErugun9TgAH7yz+sa/2mMDeOYQAAAJgBSPJKAUjy
SgAAAAtzc2gtZWQyNTUxOQAAACCO4k4/VekVHrQZxeRzErugun9TgAH7yz+sa/2mMDeOYQ
AAAEC2LNF1VVtTYMGeKBd52GrP04CAGL3sbb8k6kbL6Dtb1I7iTj9V6RUetBnF5HMSu6C6
f1OAAfvLP6xr/aYwN45hAAAAEHJqcmVnN0BnbWFpbC5jb20BAgMEBQ==
-----END OPENSSH PRIVATE KEY-----
The same I have added but it is not working

4 replies
@cjjohansen

you are trying to add the private key. you should add the public key

@Khun111

Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Belial/.ssh/id_rsa): cat id_rsa.pub | clip
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in cat id_rsa.pub | clip
Your public key has been saved in cat id_rsa.pub | clip.pub
The key fingerprint is:
SHA256:ydz2Vrqiect4jnNctrs5nznPs79V8Z86DqCTNUNBw28 Belial@DESKTOP-GQTJA50
The key's randomart image is:
+---[RSA 3072]----+
| o+ |
| .o |
| .. . |
| o.o E o|
| S=+ . o|
| +.+.oo +|
| + . ++. .o|
| o=.++o=.|
| =B+o
B==O|
+----[SHA256]-----+
please help, I have same error

@airtower-luna

That's not an error, you told ssh-keygen to save the new key in a file called cat id_rsa.pub | clip. That doesn't make a lot of sense, but it worked. 😅

Most likely what you actually want is to accept the default output file, and after key generation copy the public key to the clipboard. 🙂

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

0 replies

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 .pub file. That file contains the public key. 🙂

0 replies

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.

2 replies
@HannahNguyen6729

HI stanflows, thank you for your comment, it helps me a lot. i have the same problem

@stanflows

I'm glad it helped you. 👍

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/id_ed25519.pub

0 replies

@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.

0 replies

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?

0 replies

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

0 replies

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.

0 replies

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?

0 replies

Not really…how do I get it

0 replies

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”

0 replies

when you run the following code in your terminal:

pbcopy < ~/.ssh/id_ed25519.pub

it copies the public key to your clipboard, so just paste it into the key section.

0 replies

Hello , I’m trying to add a SSH Key to my github but It keeps saying “Key is invalid. You must supply a key in OpenSSH public key format.” I’ve read some of yawls solutions, but I still cant figure it out. And I cannot find id_ed25519.pub. Please help me solve this issue, thank you.

1 reply
@AnxiousLeopard

I just had the same issue and realised that there is a Microsoft Publisher document appearing when the file is marked as ".pub"
If you right click this and open it in notepad you will have your public key.

Where the key files are stored depends on the exact OS and SSH client you are using. Also the file itself may have a different name if you use another algorithm, e.g. id_rsa.pub. If you provide those details, maybe someone will have an idea.

0 replies

HI @GustavoTijerino1,

I would recommend you try following the steps exactly detailed in the document link below.
connecting-to-github-with-ssh
If you then still experience a problem it will be much easier to determine the cause. In most cases following these instructions exactly will solve your problems.

0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet