SSH 身份验证有效,但 git clone 无效

SSH 身份验证有效,但 git clone 无效

我在 Windows 10 上,我真的很困惑为什么我不能从 bitbucket 克隆一个仓库。我生成了一个密钥对,并将公钥添加到我的 bitbucket 帐户,将私钥添加到 ssh-agent。ssh-add -l显示:C:\Users\"username"\.ssh\id_rsa (RSA),这是正确的密钥。现在,即使尝试使用 ssh 连接到 bitbucket:也会返回许多其他行:ssh -vT [email protected]

debug1: identity file C:\\Users\\<username>/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: Host 'bitbucket.org' is known and matches the RSA host key.
debug1: Found key in C:\\Users\\<username>/.ssh/known_hosts:2
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:9CVIiWqSy1eKuUS7yhmwum6VgKrW/tJE0/T2PWdAWmQ C:\\Users\\<username>/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
**debug1: Authentication succeeded (publickey).**
Authenticated to bitbucket.org ([18.205.93.2]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
logged in as <user>

You can use git or hg to connect to Bitbucket. Shell access is disabled

但是当我尝试克隆我的 repo 时,git clone <repo_url copy pasted from bitbucket directly>我得到了:

Cloning into '<repo_name>'...
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

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

查看 repo 的设置,我确实有写入权限。我真的不知道到底出了什么问题……有什么想法吗?https 可以工作,所以不可能是权限问题。但我想使用 ssh。奇怪的是 key_load_public 找不到密钥,即使它存在,但后来出于某种原因身份验证仍然成功。

答案1

有可能,您可能已添加访问密钥,这些密钥在特定于您尝试克隆的存储库的设置中可用。它们提供对存储库的只读访问权限。参见下图。

在此处输入图片描述

确保您已在 Bitbucket 帐户设置中添加了 ssh 密钥,然后再次检查。

相关内容