报错
当我使用git clone git@github.com:…的时候,报错:Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
解决办法
1.本地生成ssh key
$ ssh-keygen -t rsa -C “youremail@example.com”
替换成你的邮箱,然后输入设置一个密码
2.测试
$ ssh -v git@github.com
到最后会出现:
3.
$ ssh-agent -s
然后会出现以下信息:
4.
$ ssh-add ~/.ssh/id_rsa
输入你设定的密码,之后打开你生成的id_rsa.pub将里面的内容粘贴到你的github帐号中:
settings->SSH and GPG keys->new SSH key
随便起一个名字,把id_rsa.pub里面的内容粘贴上去,然后ok。
5.验证
$ ssh -T git@github.com
6.若出现如下信息,则表示成功。
Hi itsalpha! You’ve successfully authenticated, but GitHub does not provide shell access.