Fix ssh Git connection against Azure DevOps

I recently had the issue against my on premise Azure DevOps server, that the clone via ssh would fail with the message:

PS C:\Users\goa> git clone ssh:// %SERPROFILE%\workspaces\java\
Unable to negotiate with port 22: no matching host key type found. Their offer: ssh-rsa
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

The error can look different depending on if you already have a configuration file for SSH or not. But in any case, if a error is thrown, it is likely that the keys are the culprit. Fortunately this is easy to solve. Create the following file

notepad %USERPROFILE%\.ssh\config

and add the following content.

    User git
    PubkeyAcceptedAlgorithms +ssh-rsa
    HostkeyAlgorithms +ssh-rsa
    AddressFamily inet

Modify it of course with your specifications (i.e. hostname).

One could ask why “AddressFamily inet”. Well, shame on me, I don’t have IPv6 not properly set up due to a lack of understanding. So now I rely on IPv4 (what this line configures) in order to not have to wait for a timeout every time I’d like to clone something.