码迷,mamicode.com
首页 > 其他好文 > 详细

How to clone a repository from Github

时间:2017-08-16 15:32:21      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:github   public key error   

Assume we are on a server, and we would like to clone a repsitory from Github.

Once we hit git clone git@github.com: repository name, an error was prompted:

Permission denied (publickey).
fatal: Could not read from remote repository.

Why is that? Because we haven‘t added our SSH key to the github account.


To resolve this issue, 

first, turn on the ssh-agent;

eval "$(ssh-agent -s)"

Then, verify that there is a private key generated and loaded into SSH, by command:

ssh-add -l

However, we found nothing in there.

GitHub says, if it does not generate anything, you should either generate a new SSH key, or use an existing SSH key, and associate it with GitHub.

So, we go and check if there is already an SSH key available, we use the command:

ls -al ~/.ssh

There it is. We found a key pair named id_rsa.pub and id_rsa.

We add our SSH private key to the ssh-agent, with command:

ssh-add ~/.ssh/id_rsa

Finally, we reach the last step, that is, to add the SSH key to GitHub account.

0) Copy the SSH key to your clipboard, which is

~/.ssh/id_rsa.pub

1) Go to Settings of your GitHub account, 

2) Click SSH and GPG keys,

3) Click New SSH key or Add SSH key,

4) Add description to the title;

5) Paste the key into the "Key" field.


We are done.


Reference:

https://help.github.com/

本文出自 “胡一刀” 博客,请务必保留此出处http://11190017.blog.51cto.com/11180017/1956601

How to clone a repository from Github

标签:github   public key error   

原文地址:http://11190017.blog.51cto.com/11180017/1956601

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!