问题描述:
最近刚刚学爬虫,从学长的git上clone到服务器的时候 出现的这个问题,问题不大吧,估计以后还会遇到。
问题很简单,就是没有秘钥,显然github不知道你是谁,然后禁止你拉取代码。
原理:本地生成秘钥,然后添加到GitHub里面 DONE
解决方法:
1.本地生成秘钥:
ssh-keygen -t rsa -C "username" // username = 你的git用户名
然后一路 enter 下来,可能会遇到 overwrite 的问题,如果有遇到 请大家 根据情况自行选择 y/n
成功后 会显示
// 上面有两行内容关注下,这里面 红色内容即为你的本地的存储秘钥的地方,一会要去这个地方查看秘钥
Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa):
2.找到刚刚生成的秘钥:
cat /root/.ssh/id_rsa.pub
然后复制你的全部内容
3.到GitHub上添加 SSH key
Github添加SSH key的界面 : https://github.com/settings/profile
然后添加进去,并且给自己的秘钥起一个title 然后就OK啦!
然后就去愉快的 git clone 吧!