如何找出推送时 bitbucket 使用的 public 键?

How to find out which public key bitbucket uses when pushing?

我在推送到 bitbucket 存储库时遇到问题,我收到了这条消息:

    Pushing to ssh://git@bitbucket.org/banana/pera.git
    Permission denied (publickey).
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.
    Pushing to ssh://git@bitbucket.org/banana/pera.git
    Permission denied (publickey).
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.
    Pushing to ssh://git@bitbucket.org/banana/pera.git
    Permission denied (publickey).
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.
    Pushing to ssh://git@bitbucket.org/banana/pera.git
    Permission denied (publickey).
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.

在这里和 Atlassian 的论坛上阅读了一些答案,我看到要测试我的密钥是否正确,我应该使用:ssh -T hg@bitbucket.org。我做到了,我得到了 Permission denied (publickey).

我现在的问题是知道它使用了哪个文件,这样我就可以给它适当的权限。我怎么做? ~/.ssh/下的所有文件都有700权限。我正在使用 Macbook。

感谢您的帮助

最简单的方法是使用 ssh-agent

使用 ssh-addssh-add $privatekey 将您的密钥添加到代理。

使用ssh-add -L打印public密钥,检查是否与bitbucket上的相同。

现在尝试 sshgit clone 应该可以。