在Win7 x64上,
执行git push 遇到 access denied
排查时,发现git pull也一样遇到access denied
原因:
之前,~/.ssh/id_rsa.pub(git bash路径,此例为 C:\Users\Administrator\.ssh目录,)
存放了注册于另一个git仓库(gitlab srv A)的另一个email (email A)的SSH pub key
而注册于当前git仓库(gitlab srv B)的当前email(email B) 生成的SSH pub key放到了~/.ssh/id_rsa_new.pub。
而其余设置已经按照服务器上的指南设好。
备份~/.ssh/id_rsa.pub后,
试图执行 cat ~/.ssh/id_rsa_new.pub > ~/.ssh/id_rsa.pub,似乎没有生效。
所以手动进入 ~/.ssh,
手动重命名了这两个.pub文件及其对应无后缀文件
~/.ssh/id_rsa.pub改为~/.ssh/id_rsa_old.pub
~/.ssh/id_rsa改为~/.ssh/id_rsa_old
~/.ssh/id_rsa_new.pub改为~/.ssh/id_rsa.pub
~/.ssh/id_rsa_new改为~/.ssh/id_rsa
之后OK。