Why might GitHub report a public key as invalid?

12,069

Solution 1

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.

Solution 2

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

Share:
12,069
Rajani
Author by

Rajani

Updated on June 04, 2022

Comments

  • Rajani
    Rajani almost 2 years

    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?