Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git SSH public key authentication failed with git on Azure DevOps

I am trying to push a git repo from PowerShell into an Azure DevOps repo, and I keep getting different auth errors when trying to push it.

I am hoping somebody can shed some light on what I check, and do a proper walkthrough.

E.g.,

git remote add origin [email protected]:v3/MyAzure/MyProject/MyRepo git push -u origin --all 

I keep getting:

[email protected]'s password:

I've input all sorts of passwords, but it's still failing. Which password is it talking about?

Alternatively, I've also gotten:

Permission denied, please try again.

fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

Verification:

$ ssh -T [email protected] ssh: connect to host mycompany.com  port 22: Connection refused 

I have done the following:

  • Created a repo in Azure DevOps
  • Created a SSH key using git-bash, as per Microsoft's documentation, copied and pasted without spaces into Azure DevOps security.
  • Gone to my profile/security and added an SSH key (generated in git-bash)

Am I missing the obvious? Is it better to use personal access token? Can anyone provide a walk through of the correct steps?

like image 271
developer9969 Avatar asked Oct 25 '18 08:10

developer9969


People also ask

How do I get my SSH key from Azure DevOps?

Open your security settings by browsing to the web portal and selecting your avatar in the upper right of the user interface. Select SSH public keys in the menu that appears. Select + New Key. Copy the contents of the public key (for example, id_rsa.

What is SSH public key in Azure?

An SSH key is created as a resource and stored in Azure for later use. You can also create keys with the Azure CLI with the az sshkey create command, as described in Generate and store SSH keys.


1 Answers

This worked for me

adding a config file in ~/.ssh/

and adding these lines

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

This link by @wcoder helped

like image 131
superjisan Avatar answered Sep 17 '22 08:09

superjisan