38

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 git@ssh.dev.azure.com:v3/MyAzure/MyProject/MyRepo
git push -u origin --all

I keep getting:

git@ssh.dev.azure.com'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 myemail@mycompany.com
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?

Community
  • 1
  • 1
developer9969
  • 3,602
  • 4
  • 30
  • 69
  • 1
    please follow [this](https://docs.microsoft.com/en-us/azure/devops/repos/git/use-ssh-keys-to-authenticate?view=vsts) step by step instruction – Jayendran Oct 25 '18 at 10:52
  • 1
    I did .shall I redo it? – developer9969 Oct 25 '18 at 11:54
  • did the `Git clone git@ssh.dev.azure.com:v3/fabrikam-fiber/FabrikamFiber/FabrikamFiber` works fine ? – Jayendran Oct 26 '18 at 02:22
  • 1
    @Jayendran it asks me enter passphrase for key .ssh/id_rsa ,left it empy and press enter and then asks me for git@ssh.dev.azure.com's password – developer9969 Oct 26 '18 at 04:35
  • 1
    @Jayendran I have the same issue, I enter the passphrase I setup for my ssh key, but then I'm asked for the `git@ssh.dev.azure.com's password` – Schalton Nov 05 '18 at 13:50
  • https://stackoverflow.com/questions/43868402/cloning-a-git-repo-from-vsts-over-ssh-asks-a-password-unexpected indicates that we're being prompted for the password because the SSH validation is failing – Schalton Nov 05 '18 at 13:53
  • In case someone runs into this problem when trying to use Pageant on windows: the solution is to put the path of your plink.exe file in an environment variable named "GIT_SSH" – Joe Sep 08 '19 at 13:16
  • look at the official doc [I have multiple SSH keys. How do I use different SSH keys for different SSH servers or repos?](https://docs.microsoft.com/en-us/azure/devops/repos/git/use-ssh-keys-to-authenticate?view=azure-devops&tabs=current-page#q-i-have-multiple-ssh-keys--how-do-i-use-different-ssh-keys-for-different-ssh-servers-or-repos) – vladimir May 06 '20 at 09:34

15 Answers15

40

This worked for me

adding a config (a file named config) file in ~/.ssh/

and adding these lines

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

This link by @wcoder helped

Devin Rhode
  • 20,940
  • 6
  • 51
  • 67
superjisan
  • 1,044
  • 10
  • 14
  • 1
    Thank you! I have forgotten "ssh." in the front of the "Host" entry in my config file. Your solution works fine! – Jordan Sep 21 '20 at 13:23
  • What does your config file look like? Can you provide a link to what this file is supposed to be? – jbooker Nov 09 '20 at 21:36
  • this worked for me too, I have an id_ed25519 for github and an entry in the config file that I think was hit as wildcard (*) which obviously did not work for azure. – noppe Dec 10 '20 at 09:54
22

Before this I had already tried the other answers, but nothing worked. At last, this article had the solution for me in Fedora.

Running ssh with the -v switch (ssh -v -T git@ssh.dev.azure.com) revealed this error:

debug1: send_pubkey_test: no mutual signature algorithm

Workaround is to add this line to the client configuration file (~/.ssh/config):

PubkeyAcceptedKeyTypes +rsa-sha2-256,rsa-sha2-512
Eddy Castillo
  • 321
  • 2
  • 3
19

I believe @Schalton's comment is right: SSH validation is failing, so it prompts for the pass.

Had the same problem. "Solved it" by generating the key as the default value ('id_rsa') instead of using other names (tried other names and none of them worked).

[####@#### .ssh]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/guille/.ssh/id_rsa): id_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.

EDIT: As noted by @LHM the value default (no input needed) for the file in which to save the key is showed in parenthesis.

eltbus
  • 387
  • 5
  • 15
  • i have a file with same name id_rsa.pub in /home/ubuntu/.ssh/ <> but am still getting this message "git@ssh.dev.azure.com's password:" in the shell. Can any one explain this – Ahmer Saeed Jul 12 '19 at 16:17
  • This helped a lot man! Just solve my problem generating the new key – Mauro Vinicius Nov 24 '21 at 16:22
11

TL;DR: It turns out the path and filename shown in parenthesis (e.g./home/guille/.ssh/id_rsa) is a default value that can be accepted simply by leaving it blank and hitting Enter.


Extended Answer: I, too, had the same problem. I made the same mistake as @eltbus (attempting to name the file something myself), so his answer of sticking to the default of "id_rsa" was helpful to me. I also realized that when I generated the rsa key pair, I saved id_rsa.pub to the wrong folder. (Only entering id_rsa without a leading file path, can save it to a different folder.)

You can avoid both of my above mistakes if you simply hit Enter to accept the default file name and location, instead of typing in a path and/or file name.

Example:

[####@#### .ssh]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/guille/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.
LHM
  • 641
  • 11
  • 30
  • 1
    leaving the file name blank did the trick for me. it will still not work even if you enter the same file name id_rsa as it will save it in the parent folder. – Saj Feb 19 '20 at 02:08
10

I realize this question mentions powershell. However, with the title and tags people on other OS's may end up here, and there is a common problem with Azure Devops access from mac and linux.

To fix this for mac and linux, add IdentitiesOnly yes to ~/.ssh/config

This is a common problem for Azure Devops. Unfortunately I'm not certain why this fixes it.

Jack Davidson
  • 3,893
  • 2
  • 27
  • 31
  • 3
    Yes, you are right! [DevOps Q&A](https://docs.microsoft.com/en-us/azure/devops/repos/git/use-ssh-keys-to-authenticate?view=azure-devops&tabs=current-page#q-i-have-multiple-ssh-keys--how-do-i-use-different-ssh-keys-for-different-ssh-servers-or-repos) – wcoder Mar 15 '20 at 20:27
3

I have the same problem.

My solution was:

The path while I try to use sudo git clone... doesn't have permission to access my public and private key location: \home\localuser\.ssh\....

To solve this, I change ownership of the destination path to the same user:group ware my keys are stored and avoid to use sudo git clone...., now im using git clone without sudo and everything works.

I hope you understand...

  • 1
    Is this really the same problem? Reading the question, I think it is different to the one you were trying to solve. Your problem is about cloning using `sudo` (which is a bad idea). The actual question appears to be about setting up an SSH key correctly. – Stephen C Sep 28 '19 at 03:50
2

I saw my repo ssh URL which was different from my DevOps URL in my case what worked was adding the config file in my ~/.ssh folder with the following information:

Host vs-ssh.visualstudio.com <-- hostname found in my repo SSH URL
    IdentityFile ~/.ssh/id_rsa_vsonline <-- your key name
    IdentitiesOnly yes

then tested it with

ssh -v vs-ssh.visualstudio.com

in the trace, I got something like

Authenticated to vs-ssh.visualstudio.com ([IP]:22).

pedrommuller
  • 15,360
  • 9
  • 71
  • 124
1

When you paste in the key on the settings page of Azure DevOps don't change anything including the space appended at the end of the public key.

1

I was using the GitHub recommended Ed25519 algorithm key which Azure DevOps doesn't support so I generated a standard key. The problem was I forgot to add the key:

ssh-add -k ~/.ssh/id_rsa
tijko
  • 6,839
  • 11
  • 40
  • 56
GentryRiggen
  • 708
  • 10
  • 10
0

I followed the official permissions denied troubleshooting guide and it turned out, I had to re-generate the key after all. But I think it is best to follow the guide as it provides information on quite a few different scenarios that most of which are not mentioned here.

Nikita R.
  • 6,687
  • 2
  • 49
  • 59
0

Sign into your Azure DevOps. Go to Repos > Files, then click Clone. Finally, under the HTTPS tab, click Generate Git Credentials.

Jeremy Caney
  • 6,191
  • 35
  • 44
  • 70
Hesam Moosapour
  • 391
  • 2
  • 9
0

I tried every answer but with no success. It turned out it was as simple as putting the id_rsa and id_rsa.pub files in the .ssh folder under my user folder.

So by moving the files (id_rsa and id_rsa.pub) between the following locations it solved the problem and authentication succeded.

From:

C:\Users\My User\

To:

C:\Users\My User\.ssh\
Rikard Askelöf
  • 2,449
  • 3
  • 17
  • 23
0

Like Eltbus Answer, I "Solved it" by generating the key as the default value ('id_rsa') instead of using other names (tried other names and none of them worked).

Then i just followed this steps

https://docs.microsoft.com/en-us/azure/devops/repos/git/use-ssh-keys-to-authenticate?view=azure-devops#questions-and-troubleshooting

0

All who are having this issue I would verify that you dont have spaces in your project name. Spaces caused git-upload-pack to break for me using git 2.33 and 2.35.

0

In my case, I had access to two different repositories of different companies.

I had to make a new SSH Key for one project, which impacted my access to the other. The solution was:

  1. type cd ~/.ssh -> go to the .ssh folder

  2. type ls -> list what is inside; since I made a new key for the other project I obviously had these directories: id_rsa id_rsa.pub

  3. type pbcopy < id_rsa.pub -> copy the key to the clipboard

  4. Configure they key according to this documentation - Step 2: https://docs.microsoft.com/de-de/azure/devops/repos/git/use-ssh-keys-to-authenticate?view=azure-devops#configuration

For those who do not have the folders in ~/.ssh, you have to first create the SSH Key - Step 1.

MikhailRatner
  • 115
  • 3
  • 9