Issue on adding SSH key to GitHub
Asked Answered
S

8

23

I have got an issue that seems about the format of SSH key used by GitHub. I used Git Bash to generate a new SSH key:

$ ssh-keygen -t rsa -C "[email protected]"

Then, I copied the key to the SSH section in settings of my GitHub account page. However, it came with the issue notice as follows:

Key is invalid. It must begin with 'ssh-ed25519', 'ssh-rsa', 'ssh-dss', 'ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp384', or 'ecdsa-sha2-nistp521'. Check that you're copying the public half of the key

Following that, I edited my SSH key starting with ssh-rsa and my email address at the end. However, the issue is still there.

What is the solution to this? 

Sfumato answered 24/2, 2016 at 20:33 Comment(3)
Looks like it has happened with you, because you've tried to add your private key instead of public oneLamontlamontagne
make sure it's the id_rsa.pubHalliday
https://mcmap.net/q/47182/-password-authentication-is-temporarily-disabled-as-part-of-a-brownout-please-use-a-personal-access-token-instead-duplicateMonogyny
C
13

Simply follow these steps and you will set up your SSH key in no time:

  • Generate a new ssh key (or skip this step if you already have a key) ssh-keygen -t rsa -C "your@email"

  • Once you have your key set in home/.ssh directory (or Users/<your user>.ssh under windows), open it and copy the content


How can I add the SSH key to the GitHub account?

  • Login to the GitHub account

  • Click on the rancher on the top right (Settings)

    GitHub account settings

  • Click on the SSH keys

    SSH key section

  • Click on the Add SSH key

    Add SSH key

  • Paste your key and save

And you are all set to go :-)

Crinite answered 24/2, 2016 at 20:50 Comment(3)
Easy way to grab this key to copy/paste into GitHub is using their suggested: clip < ~/.ssh/id_rsa.pub commandHalfandhalf
For those of us who make things harder than they have to be, also ensure that you are using the text from the .pub file.Ambidexter
help.github.com/en/enterprise/2.15/user/articles/…Joyance
E
34

ssh-keygen will generate you a pair of keys, one private and one public. It sounds like you uploaded the wrong one. GitHub wants the public key, typically here: ~/.ssh/id_rsa.pub.

Epiphyte answered 24/2, 2016 at 20:37 Comment(2)
Thanks! Yep, I just found one ending with .pub so that is the right and works properly!Sfumato
Wow. This was my problem as well. I feel like a donkey. Thank youFeckless
C
13

Simply follow these steps and you will set up your SSH key in no time:

  • Generate a new ssh key (or skip this step if you already have a key) ssh-keygen -t rsa -C "your@email"

  • Once you have your key set in home/.ssh directory (or Users/<your user>.ssh under windows), open it and copy the content


How can I add the SSH key to the GitHub account?

  • Login to the GitHub account

  • Click on the rancher on the top right (Settings)

    GitHub account settings

  • Click on the SSH keys

    SSH key section

  • Click on the Add SSH key

    Add SSH key

  • Paste your key and save

And you are all set to go :-)

Crinite answered 24/2, 2016 at 20:50 Comment(3)
Easy way to grab this key to copy/paste into GitHub is using their suggested: clip < ~/.ssh/id_rsa.pub commandHalfandhalf
For those of us who make things harder than they have to be, also ensure that you are using the text from the .pub file.Ambidexter
help.github.com/en/enterprise/2.15/user/articles/…Joyance
B
5

If you are using a Mac and are typing out GitHub's instructions (e.g. Generating a new SSH key and adding it to the ssh-agent, you're probably typing and only tabbing (e.g. auto-completing) to:

$ pbcopy < ~/.ssh/id_rsa

and not

$ pbcopy < ~/.ssh/id_rsa.pub

With the former you're actually copying, and trying to paste your private key.

I hope that saves you some time.

Bedder answered 27/2, 2016 at 7:42 Comment(1)
sometimes I feel like a nut. sometimes I don't.Acclimatize
M
3

Another way to copy the public key to the clipboard:

clip < ~/.ssh/id_rsa.pub
Mckay answered 10/6, 2018 at 3:0 Comment(1)
What platform? Ubuntu? Is clip installed by default?Courtesy
T
2

Open file ~/.ssh/id_rsa.pub. Then open it with an editor and copy the public key to your GitHub account.

Taeniasis answered 1/11, 2016 at 0:5 Comment(0)
M
2

I ran into the same problem and it turns out it was due to there being a - in the comment. GitHub apparently doesn't like -, but _ is OK though.

Marquita answered 5/6, 2017 at 17:51 Comment(0)
S
1

Add SSH key to Github

Check if you have a key?

ssh-add -l

If not? then follow steps to generate key

ssh-keygen -t rsa -b 4096 -C your__gmail

Now for copy the key use xclip tool or just goto file and copy

sudo apt install xclip
xclip -sel clip < ~/.ssh/id_rsa.pub
  • Now goto github.com and goto settings
  • select SSH and GPG keys
  • New SSH key
  • Enter "your__choice__name" in title field...
  • Paste your public key into the Key field
  • Click Add SSH key
Sigman answered 7/9, 2020 at 5:29 Comment(0)
L
0

For IntelliJ IDE,

Go to IntelliJ IDEA -> Preferences... enter image description here

Lucilucia answered 21/8, 2021 at 20:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.