Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub error - Key is invalid. You must supply a key in OpenSSH public key format

EDIT: solved I was opening id_ed25519 not id_ed25519.pub.

When I try to paste my SSH key into GitHub > Settings > SSH and GPG keys > New SSH key, I get the error:

Key is invalid. You must supply a key in OpenSSH public key format

I created the SSH key and added it to the SSH agent successfully as per these instructions in Generating a new SSH key and adding it to the ssh-agent

I found the file and copied the key to my clipboard using these instructions in Adding a new SSH key to your GitHub account

But the text field "Key" in https://github.com/settings/ssh/new says: Begins with 'ssh-rsa'... and then gives a whole other variety of ways the key can start.

But mine starts:

-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAA

Can anyone help me please? I followed the instructions to the letter. Do I need to add something like 'ssh-rsa' to my key for it to work?

like image 948
Gus Avatar asked Sep 09 '25 18:09

Gus


1 Answers

When you create ssh keys you get 2 key's.

One is the public key with "*.pub" and one private key.

You can read both keys if you open the files.

The private key begins with something like:

----BEGIN OPENSSH PRIVATE KEY-----

The public key starts with the Digital Signature Algorithm it is a one row string

You have to copy the "*.pub" to the git server or on other servers if you work with ssh.

Never give away your private key and use always a password with your keys if someone copy or steal the private key.

like image 120
ReflectYourCharacter Avatar answered Sep 12 '25 07:09

ReflectYourCharacter