git - 如何从 Bitbucket 存储库推送到 Azure 存储库,不同的用户电子邮件

标签 git ssh

我在 的一个分支中有一些代码比特桶 我需要将它们推送到 中类似 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/

相关文章:

c# - EFCore 迁移是否应该致力于版本控制?

linux - 如何在多台机器上使用相同的 ssh key ?

通过 SSH v2 协议(protocol)的 java RMI

python - 使用 pysftp 和 Python 3 仅使用服务器指纹连接到 SFTP 服务器

php - 如何使用 PHP 和远程 ssh 从文本文件中获取信息?

git - 如何从 Android Studio 项目中删除 Git?

git - 为什么 git pull 之后会出现本地提交?

amazon-web-services - AWS EC2权限被拒绝

git - 在 git checkout-index 中也包括子模块

php - 使用 composer 开发库的最佳方式是什么?