基于 GitBucket SSH 的身份验证

GitBucket SSH Based Authentication

我将基于 SSH 的身份验证配置如下

然后尝试推送,但出现以下错误:

Permission denied (public key). fatal: Could not read from remote repository. 
Please make sure you have the correct access rights and the repository exists.

我有存储库的读写权限 推送命令 git push -u origin master

有什么想法吗?

你应该试试:

GIT_SSH_COMMAND="ssh -Tv" git push

您将看到 Git 正在使用什么作为 SSH 密钥,以及是否有任何错误消息。

如果错误仍然存​​在,可能是有什么东西阻止了 SSH 正常运行(,当没有连接到 VPN 时)

当然,使用 HTTPS 是一种解决方法:

git remote set-url origin https://git@bitbucket.XXX.com/XXX.com/XXX.git

discussion 之后,缺少的步骤是将私钥添加到 ssh-agent

ssh-add OEDQ_BIT added the private key