问题描述
我有多个ssh密钥,一个项目使用一个密钥。我已经成功地将public ssh密钥分配给我的bitbucket帐户中的相关存储库。
它们存储在以下位置:
的〜/ .ssh / rsa_generic_repos
的〜/ .ssh / rsa_generic_repos.pub
的〜/ .ssh / rsa_project1
的〜/ .ssh /rsa_project1.pub
然后在尝试任何git访问之前将这些密钥添加到我的ssh-agent中:
SSH-添加的〜/ .ssh / rsa_generic_repos
的ssh - 添加的〜/ .ssh / rsa_project1
ssh-add -l - 显示:
4096 SHA256:XXXXXXXXXXXXXXXXXXXXXXXXXXX / XXXXXXXXXXXX通用回购密钥(RSA)
4096 SHA256:XXXXXXXXXXXXXXXXXXXXXXXXXXX / XXXXXXXXXXXX项目1密钥(RSA)
我的问题: 这个工作正常(克隆回购): 这不work: 错误: 然而,如果我运行: 它成功克隆以前不会的回购。这首先建议公钥正确设置在bitbucket上,并且ssh守护进程不会尝试使用第一个入口以外的任何ssh密钥,因此会导致上述错误。 如果任何人都可以通过一种方法让ssh通过存储在ssh-agent会话中的所有密钥,我将非常感激。 谢谢给你的帮助和时间。 使用多个ssh密钥的正确方法是 你可以像使用ssh url一样使用 使用一个部署密钥确实更容易,但我想说明配置ssh功能,它允许您使用任意数量的密钥。 I have multiple ssh keys, using one key for one project. I have successfully assigned the public ssh keys to the relevant repositories inside my bitbucket account. They are stored in the following location: I then add these keys to my ssh-agent before attempting any git access: ssh-add -l - Displays: My Problem: This works correctly (clones the repo): This does not work: Error: Yet if I run: It successfully clones the repo which it previously wouldn't. This suggests firstly that the public key is set up on bitbucket correctly and that the ssh daemon is not attempting to use any ssh key other than the first entry therefore resulting in the above error. If anyone could help me with a way to get ssh to go through all the keys stored in the ssh-agent session I would be tremendously grateful. Thank you for your help and time. The proper way to use multiple ssh keys would be to And you would use ssh url like Using one deployment key is indeed easier, but I wanted to illustrate the config ssh feature which allows you to use any number of keys. 这篇关于访问bitbucket回购多个键时git ssh授权错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
git clone [email protected]:Myusername / generic-repo.com.git
git clone [email protected]:Myusername / project1.com.git
克隆到'project1 '...
存取库访问被拒绝。部署密钥未与请求的存储库相关联。
致命:无法从远程存储库读取。
请确保您拥有正确的访问权限并存在存储库。
ssh-add -D
ssh-add〜/ .ssh / rsa_project1
git clone [email protected]:Myusername / project1.com.git
〜/ .ssh / config
文件,如
'pre> 主机bbgeneric
主机名bitbucket.org
IdentityFile的〜/ .ssh / rsa_generic_repos
的用户的git
主机bbproject1
主机名bitbucket.org
IdentityFile的〜/ .ssh / rsa_project1
的用户的git
$ b $ p
bgeneric Myusername / gener ic-repo.com.git
bbproject1:Myusername / project1.com.git
~/.ssh/rsa_generic_repos
~/.ssh/rsa_generic_repos.pub
~/.ssh/rsa_project1
~/.ssh/rsa_project1.pub
ssh-add ~/.ssh/rsa_generic_repos
ssh-add ~/.ssh/rsa_project1
4096 SHA256:XXXXXXXXXXXXXXXXXXXXXXXXXXX/XXXXXXXXXXXX Generic Repo Key (RSA)
4096 SHA256:XXXXXXXXXXXXXXXXXXXXXXXXXXX/XXXXXXXXXXXX Project 1 Key (RSA)
git clone [email protected]:Myusername/generic-repo.com.git
git clone [email protected]:Myusername/project1.com.git
Cloning into 'project1'...
repository access denied. deployment key is not associated with the requested repository.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
ssh-add -D
ssh-add ~/.ssh/rsa_project1
git clone [email protected]:Myusername/project1.com.git
~/.ssh/config
file, as I describe hereHost bbgeneric
Hostname bitbucket.org
IdentityFile ~/.ssh/rsa_generic_repos
User git
Host bbproject1
Hostname bitbucket.org
IdentityFile ~/.ssh/rsa_project1
User git
bbgeneric:Myusername/generic-repo.com.git
bbproject1:Myusername/project1.com.git