“Key is invalid” message on GitHub

后端 未结 18 1980
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-30 01:49

I have generated SSH keys for a new server installation according to the procedure outlined here. However, when I copy the contents of id_rsa.pub to my keys list on

相关标签:
18条回答
  • 2021-01-30 02:30

    Just for those looking in the future, another common issue is that word-wrapping. For example, if you run cat ~/.ssh/id_rsa.pub it could wrap lines, thus adding extra \ characters at each line break. Remove these and your key should work fine.

    0 讨论(0)
  • 2021-01-30 02:34

    If you have indeed copied the content of your id_rsa.pub key (in one continuous line), the result should look like (from The GitHub ssh help page):

    ssh key

    The OP louism confirms a copy-paste issue:

    • For a very obscure reason, copy-pasting from emacs removed the \n after ssh-rsa, and that was causing the problem.
    • Copy-pasting from vi solved the problem.
    0 讨论(0)
  • 2021-01-30 02:36

    Here are some steps that are not at all clear when copy/pasting your public key. (For the record, I used Putty Key Generator for my keys.)

    • On the first line, enter ssh-rsa.
    • Make sure you add one space after ssh-rsa
    • When you copy/paste the key into the Key textbox it should preserve the \n characters (x0A). If you are using Notepad on Windows, you won't see these new lines until you copy the text to Github.

    Notice on this screenshot, there's a space after ssh-rsa (See the cursor.) The public key text also includes three \n characters, so you can see the public key text bumps down to the next line three times in the textbox.SSH RSA Key

    0 讨论(0)
  • 2021-01-30 02:36

    if using vs code

    code ~/.ssh/id_rsa.pub will open .pub file copy it to github

    0 讨论(0)
  • 2021-01-30 02:41

    I just had this issue. Super frustrating. I figured my situation might have affected the casue of the problem. I am using a tablet, trying to setup the key on githubs site through my tablet browser (Chrome) and I am copying the key from an ssh app connected to my remote linux server.

    What ended up happening is that somehow when I copied the key to the browser, it introduced a number of line breaks. Not only that, but it also removed a character from each point where a new line was inserted.

    So to get it to work, I had to manually find each new line break, then hunt for that part of the key to find the missing character. I then added the character and removed the new line. After I hunted down each and every change, the key worked fine.

    By the way, I did not add any new line breaks myself, such as the one mentioned by others after the ssh-rsa.

    Hopefully this helps others. I have no idea why it happened. Silly that copying to the clipboard would alter the text copied. Oh, I also copied it right out of Vim.

    0 讨论(0)
  • 2021-01-30 02:44

    In my case, I had to add an extra white rule after my e-mail (after the entire key string) before it got accepted. I found this out by accident, after trying to copy my ssh key as entered on Gitlab.

    pbcopy from my pub key straight form the command line didn't work. The copy from gitlab with the extra white rule at the end, did the trick.

    0 讨论(0)
提交回复
热议问题