ssh_exchange_identification: Connection closed by remote host under Git bash

后端 未结 26 2525
梦谈多话
梦谈多话 2021-01-30 08:57

I work at win7 and set up git server with sshd. I git --bare init myapp.git, and clone ssh://git@localhost/home/git/myapp.git in Cywgin

26条回答
  •  日久生厌
    2021-01-30 09:28

    We migrated our git host instance/servers this morning to a new data center and while being connected to both: VPN (from remote/home) or when in office network, I got the same error and was not able to connect to clone any GIT repo.

    Cloning into 'some_repo_in_git_dev'...
    ssh_exchange_identification: Connection closed by remote host
    fatal: Could not read from remote repository.
    

    This will help if you are connecting to some or all servers via a jump host server.

    Earlier in my ~/.ssh/config file, my setting to connect were:

    Host * !ssh.somejumphost.my.company.com
         ProxyCommand ssh -q -W %h:%p ssh.somejumphost.my.company.com
    

    What this means is, for any SSH based connection, it will connect to any * server via the given jump host server except/by ignoring "ssh.somejumphost.my.company.com" server (as we don't want to connect to a jump host via jump host server.

    To FIX the issue, all I did was, change the config to ignore git server as well:

    Host * !ssh.somejumphost.my.company.com !mycompany-git.server.com !OrMyCompany-some-other-git-instance.server.com
         ProxyCommand ssh -q -W %h:%p ssh.somejumphost.my.company.com
    

    So, now to connect to mycompany-git.server.com while doing git clone (git SSH url), I'm telling SSH not to use a jump host for those two extra git instances/servers.

提交回复
热议问题