git - 如何从 Bitbucket 存储库推送到 Azure 存储库,不同的用户电子邮件
问题描述
我在Bitbucket的一个分支中有一些代码,我需要将它们推送到Azure中类似 repo 中的一个分支。我只能使用不同的电子邮件访问这两个存储库。我已经在 Azure 中克隆了新的 repo 并在我的本地设置了 ssh 密钥。由于我必须使用不同的电子邮件,因此两个存储库的 ssh 密钥是不同的,对吗?不确定是否可以建立连接。
我在我的 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
这个链接有帮助。
基本上编辑~/.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 私钥。
推荐阅读
- ios - 划分 iOS API 可用性
- reactjs - 尝试本地模拟 API 调用......但没有被承诺错误捕获我错过了什么?(可以提供任何代码示例)
- php - 如何在 wordpress functions.php 中覆盖插件类函数?
- algorithm - 这个函数的 BigO 是什么
- azure - 在 Azure Devops 发布管道中更改 yaml 文件的分支
- c# - 使用 HttpClient 下载文件但延迟写入
- python - 如何在 Python 中测试 JPEG 是 RGB 还是 CYMK
- wordpress - 为什么 ACF 给我错误的图像输出数据?
- python - 向量生成具有条件值的 numpy 列
- python - 用于 scapy 嗅探网络流量的 PysimpleGUI 按钮回调