Invalid public ssh key

11,190

Solution 1

Got it. The public key should look like this:

ssh-rsa *public key* [email protected]

That is:

ssh-rsa<space><public key ending with ==><space><email address>

Solution 2

In Linux,after executing the above command,(xyz.pub) file will be generated in the directory you are working on. Then if you do a " cat xyz.pub ", you will get your public key which has "ssh-rsa" in the beginning. This is how it looks like Now,you need to copy paste the displayed text in your GitHub Account. Hope this will probably solve the issue. And in windows,I think you should edit the file in NotePad++

Solution 3

GitHub generates two files: one with no type, and one .pub. You need the second one with the .pub extension, that file will already have the pattern:

ssh-rsa <key> <email>

If it doesn't have this pattern, you may be looking at the wrong file.

Share:
11,190
FGreg
Author by

FGreg

Updated on July 28, 2022

Comments

  • FGreg
    FGreg almost 2 years

    Trying to follow the instructions on github for Generating SSH Keys for windows.

    I run ssh-keygen -t rsa -C "[email protected]", enter passphrase and it appears the SSH key is generated correctly.

    However, when trying to "Add SSH Key" on GitHub it gives me the error

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

    The public key generated by Windows looks like this:

    ---- BEGIN SSH2 PUBLIC KEY ----
    Comment: "2048-bit RSA, [email protected]"
    *public key*
    ---- END SSH2 PUBLIC KEY ----
    

    Most notably it does not begin with 'ssh-rsa' or 'ssh-dss'. I tried just copying the *public key* part and prepending 'ssh-rsa' to it but I get the same error on GitHub. Any ideas what I'm doing wrong?