简体   繁体   中英

How to push from Bitbucket repo to a Azure repo, different user email

I have some codes in a branch in Bitbucket and I need to push them to a branch in a similar repo in Azure . I can only access the two repos using different emails . I've already cloned the new repo in Azure and set up ssh key in my local. Since I have to use different emails, the ssh keys for the two repos are different, correct? Not sure if it's possible to make the connection.

I'm in my Bitbucket repo. Here is what I did and the error message:

> 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.

UPDATES 08/21

This Link helped.

Basically edit ~/.ssh/config and add the following:

Host ssh.dev.azure.com
IdentityFile ~/.ssh/my_ssh_private_key
IdentitiesOnly yes

The git config user.email has nothing to do with authentication.

SSH will use by default ~/.ssh/id_rsa private key, and chances are you need to dedicated private key for Azure, which differs from the one you are using for BitBucket.

So this would work:

export GIT_SSH_COMMAND='ssh -i ~/.ssh/azure_private_key'
git fetch

Or

git -c 'core.sshCommand="ssh -i ~/.ssh/azure_private_key"' fetch

Replace " azure_private_key " by your Azure private key.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM