问题信息
访问远程repo报错如下:
$ git pull
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.
git push/pull
失败后尝试将私钥文件添加到SSH代理中,返回如下信息。
$ ssh-add ~/.ssh/id_rsa_github
Could not open a connection to your authentication agent.
原因分析
在这里的问题是 ssh-add
无法连接到 SSH 认证代理。这可能是由于代理没有启动或者环境变量没有正确设置引起的。
尝试以下步骤:
-
确保
ssh-agent
正在运行:eval "$(ssh-agent -s)"
-
将密钥添加到代理:
ssh-add /d/Path/To/Your/SSH/Key
确保 SSH 密钥路径是正确的。
如果问题仍然存在,可以尝试重启 Git Bash 并重复上述步骤。如果问题仍然无法解决,可能需要检查系统环境变量以确保 SSH 相关的路径被正确设置。
解决✔️