Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why might GitHub report a public key as invalid? [closed]

I have generated ssh key.
The result was:

Your identification has been saved in /home/rajani/.ssh/id_rsa.
Your public key has been saved in /home/rajani/.ssh/id_rsa.pub.

The key is in hexa decimal format, but while adding it to GitHub, I am getting error like this:

Key is invalid. 
It must begin with 'ssh-rsa' or 'ssh-dss'. 
Check that you're copying the public half of the key .

How I should properly add an ssh key to GitHub?

like image 935
Rajani Avatar asked Jun 05 '12 12:06

Rajani


People also ask

How do I resolve permission denied public key?

This error comes up when using a wrong private key or no key at all when trying to connect via SSH. To resolve the problem, you should generate a new key pair and connect using that new set of keys.

What does Permission denied public key mean?

"Permission denied (publickey)" and "Authentication failed, permission denied" errors occur if: You're trying to connect using the wrong user name for your AMI. The file permissions within the operating system are incorrect on the instance. The incorrect SSH public key (. pub) file is in the authorized_keys file.

How do you solve key is invalid You must supply a key in OpenSSH public key format?

2 suggested answers With OpenSSH the public key should be in a file with a name ending in . pub , and the content should start with ssh- , followed by the key type (e.g. rsa or ed25519 ).


2 Answers

The Problems

  1. The ssh-keygen utility usually defaults to generating RSA keys, but your implementation may default to ECDSA, which GitHub does not currently support.
  2. If you are truly generating RSA keys, you may be trying to paste your private key to the server, instead of your public key.

Solutions

  1. Force RSA key generation by passing the -t flag to ssh-keygen.
  2. Make sure you're copying the key with a .pub extension, and that you include the entire line. This will include the ssh-rsa prefix if you're copying an RSA public key.

Related

Of course, man 1 ssh-keygen is your friend.

like image 77
Todd A. Jacobs Avatar answered Sep 23 '22 01:09

Todd A. Jacobs


You should add the "hexa decimal part" and put "ssh-rsa " in the front, that should do the trick.

like image 30
avatar Avatar answered Sep 22 '22 01:09

avatar