Using “KexAlgorithms diffie-hellman-group1-sha1” did not resolve “no matching key exchange method found” error

There’s a lot of questions about the following error, but they all have same solution which did not have any effect:

$ git push
Unable to negotiate with 192.168.XXX.XXX: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1
fatal: Could not read from remote repository.

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

There is an article on that didn’t help. Particularly this was suggested:

  • replacing a file in a git branch with the same file from another branch?
  • git-svn fetch isn't pulling in the latest versions
  • How to handle backend (laravel) and frontend (angular) dependencies in different git repos
  • How to add ssh key path to a git command terminal
  • Notorious Git Error: remote rejected (failed to lock)
  • Eclipse 'Unhandled loop exception' on Team > Commit
  • … in the ~/.ssh/config file:

    KexAlgorithms +diffie-hellman-group1-sha1

    I did exactly that. I assume that ~ resolves to %userprofile% on windows. My file is in C:\Users\MY_USERNAME\.ssh\config:

    ## use kex algorithm ##
    Host 192.168.XXX.XXX
    KexAlgorithms diffie-hellman-group1-sha1

    The result is that nothing changed. There is also suggestion to use ssh -o but I’m yet to find an answer that bothers to describe how exactly yo do that. I tried this:

    $ ssh -oKexAlgorithms=+diffie-hellman-group1-sha1
    usage: ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]

    I need to connect to that GIT repository. I am on windows. The repository uses Gerrit. I also use SourceTree and it has no problems pushing into the repository. So the repository works, but git or openSSH in my bash is broken.

    What did I do wrong that this solution didn’t work for me?

  • How to mirror trunk of svn repo into github?
  • How best to squash old commits
  • Git invert staging area
  • git line endings : renormalize does not seem to checkout the right line endings
  • git-svn cannot create a branch to follow SVN branching
  • Git push only for bare repositories?
  • 2 Solutions collect form web for “Using “KexAlgorithms diffie-hellman-group1-sha1” did not resolve “no matching key exchange method found” error”

    Resolved by using this command I randomly found in some comment thread:

    export GIT_SSH_COMMAND='ssh -o KexAlgorithms=+diffie-hellman-group1-sha1'

    Must be called every time you open the Git Bash. Yeah, git is hell.

    I resolved a similar problem on Windows 10 by updating my version of Open SSH to the latest (7.5p1-1) and then making sure that C:Program Files\OpenSSH\bin was the first entry in the system path so it used that ssh.exe and not any others.

    Git Baby is a git and github fan, let's start git clone.