Windows环境Git克隆GitHub仓库遇公钥权限异常及重复添加密钥问题求助
Git克隆SSH权限问题排查与永久解决
问题场景
在Windows系统的VS Code终端目标文件夹中执行克隆命令:
git clone git@github.com:username/shopping-list.git . Cloning into '.'... 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.
但已通过以下命令验证SSH连接正常:
ssh -T git@github.com Hi username! You've successfully authenticated, but GitHub does not provide shell access.
临时解决方法
在目标文件夹的Git Bash中执行以下命令将SSH密钥添加到SSH代理,可临时解决问题:
eval 'ssh-agent -s' ssh-add ~/.ssh/github_ssh_name
但每次克隆前都需要重复执行该添加操作。
最终永久解决
删除并重新生成一对SSH密钥后问题解决,推测原问题是因为修改了SSH密钥的默认名称。
内容的提问来源于stack exchange,提问作者Arjun Jayan
相关产品推荐
相关产品推荐

