解决方式:
不确定是否为密钥过期还是C:\Users\John\.ssh文件夹下的config文件中没有添加github的host。总之,所有的尝试如下:
(1)重新生成公钥和私钥。
- 打开git bash,输入以下命令获取自己github的email。
git config user.email
- 生成ssh私钥和公钥
ssh-keygen -t rsa -C "your email"
your email就是上面通过git config user.email输出的自己的邮箱地址
之后就会在给出的地址下生成id_rsa和id_rsa.pub 两个文件.如果之前已经有,就会提醒是否覆盖。之后一路回车
(2) 在github中添加新产生的id_rsa.pub中的内容。
然后点击ssh andGPG keys,把原来的ssh可以删掉,之后添加ssh key, 把id_rsa.pub中的内容赋值到ssh key的内容框中。保存
(3)在C:\Users\John\.ssh文件夹下的config文件中添加下面内容,保存
Host github.com User 自己的email Hostname ssh.github.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa Port 443
(4)在git bash中验证是否成功。
ssh -T [email protected]
之后发现,github成功认证。可以从上面拉代码了。
标签:github,remote,repository,rsa,id,git,报错,ssh,email From: https://www.cnblogs.com/mo-lu/p/17414312.html