我在 的一个分支中有一些代码比特桶 我需要将它们推送到 中类似 repo 中的一个分支蔚蓝 .我只能使用 访问这两个存储库不同的电子邮件 .我已经在 Azure 中克隆了新的 repo 并在我的本地设置了 ssh key 。由于我必须使用不同的电子邮件,因此两个存储库的 ssh key 是不同的,对吗?不确定是否可以建立连接。
我在我的 Bitbucket 存储库中。这是我所做的和错误消息:
> git remote -v
origin git@bitbucket.org:<repo in Bitbucket> (fetch)
origin git@bitbucket.org:<repo in Bitbucket> (push)
> git remote set-url origin git@ssh.dev.azure.com:<repo in Azure>
> git remote -v
origin git@ssh.dev.azure.com:<repo in Azure> (fetch)
origin git@ssh.dev.azure.com:<repo in Azure> (push)
> git config user.email <my email in Azure>
> git fetch
The authenticity of host 'ssh.dev.azure.com (xx.xx.xx.xxx)' can't be established.
RSA key fingerprint is SHAxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'ssh.dev.azure.com,xx.xx.xx.xxx' (RSA) to the list of known hosts.
remote: Public key authentication failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
更新 08/21
这个Link帮助。
基本编辑
~/.ssh/config
并添加以下内容:Host ssh.dev.azure.com
IdentityFile ~/.ssh/my_ssh_private_key
IdentitiesOnly yes
最佳答案
git config user.email
与身份验证无关。
SSH 默认使用 ~/.ssh/id_rsa
私钥,您可能需要为 Azure 使用专用私钥,这与您用于 BitBucket 的私钥不同。
所以这会起作用:
export GIT_SSH_COMMAND='ssh -i ~/.ssh/azure_private_key'
git fetch
或者git -c 'core.sshCommand="ssh -i ~/.ssh/azure_private_key"' fetch
将“azure_private_key
”替换为您的 Azure 私钥。
关于git - 如何从 Bitbucket 存储库推送到 Azure 存储库,不同的用户电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63143952/