
我使用的是 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
但是當我嘗試克隆我的存儲庫時: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.
查看儲存庫的設定我確實有寫入權限。我真的不知道到底出了什麼問題......有什麼想法嗎? https 可以工作,所以這不可能是權限問題。但我想使用 ssh。奇怪的是 key_load_public 找不到金鑰,即使它存在,但後來由於某種原因身份驗證仍然成功。
答案1
您可能已新增存取金鑰,這些存取金鑰在您嘗試複製的儲存庫的特定設定中可用。它們提供對您的存儲庫的唯讀存取。請參考下圖。
確保您已在 Bitbucket 帳戶設定中新增 ssh 金鑰,然後再次檢查。