git报错
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
【解决方案】
1、配置ssh
设置Git的user name和email
git config –global user.name “yourname”
git config –global user.email “youremail”
生成SSH密钥
查看是否已经有了ssh密钥:cd ~/.ssh
打开id_rsa.pub文件,复制内容粘贴到下面图示的位置
2、本次我遇到的问题是已经添加了sshkey,但还是一直报错
该问题的原因是我本地有两个sshkey,一个公司的,一个个人的;
所以需要解决的问题就是如何本地配置多个sshKey
【解决方案】:在.ssh目录下新建config文件,如图所示:
在config文件里面添加:vim config
# github
Host github.com
Port 22
HostName github.com
PreferredAuthentications publickey
IdentityFile C:\Users\username\.ssh/id_rsa_github
User yourname
# companygit
Host companygit
HostName companygit
PreferredAuthentications publickey
IdentityFile C:\Users\username\.ssh/id_rsa
User yourname
最后去检查是否成功:
ssh -T git@github.com
如果出现下面的提示即为成功