简体   繁体   中英

Git (SSH) hangs during clone/push/pull

Whenever I try and perform an operation using git (eg clone , pull , or push ) over SSH the git client seems to hang and time out indefinitely (I've left it running for half an hour to no avail). I have my SSH keys loaded (using BitBucket). I am able to perform anything I need via HTTPS, and SSH is the only thing that appears to break.

Here is some console output from an attempted pull

$ GIT_TRACE=1 git pull
16:44:05.679911 git.c:344               trace: built-in: git 'pull'
16:44:05.681453 run-command.c:334       trace: run_command: 'fetch' '--update-head-ok'
16:44:05.686650 exec_cmd.c:120          trace: exec: 'git' 'fetch' '--update-head-ok'
16:44:05.697849 git.c:344               trace: built-in: git 'fetch' '--update-head-ok'
16:44:05.703211 run-command.c:334       trace: run_command: 'ssh' '-p' '7999' 'git@git.myCompany.com' 'git-upload-pack '\''/ei/myProject.git'\'''

Anyone have any idea what could be happening?

7999 is a non-standard port which is likely to be blocked.

If port 22 is not blocked (and that is a big if), then you can consider an ssh tunneling :

ssh -R 7999:localhost:22  git@git.myCompany.com 

If you have a machine where git is working, you can compare the ssh configuration file of the nonworking to the working machine.

The ssh config file is located at /etc/ssh/ssh_config

In my case, git was working fine on Windows but not WSL2. In windows the port was set to 22 while in WSL2 it was set to 2200. I changed it to 22 and was able to continue using git on wsl2.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM