Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue on adding SSH key to GitHub

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? 

like image 535
Yu Xiong Avatar asked Feb 24 '16 20:02

Yu Xiong


People also ask

How do I know if my SSH key is working on GitHub?

Open Terminal . Enter ls -al ~/.ssh to see if existing SSH keys are present. Check the directory listing to see if you already have a public SSH key. By default, the filenames of supported public keys for GitHub are one of the following.


2 Answers

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.

like image 172
Kevin Burdett Avatar answered Oct 17 '22 00:10

Kevin Burdett


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 :-)

like image 31
CodeWizard Avatar answered Oct 17 '22 00:10

CodeWizard