I started having some issues when using git inside a Linux VM while setting up an experimental Drupal development environment. I wasn't able to clone repositories because I was getting some errors saying the remote host hanged unexpectedly, or couldn't push changes. However I was able to clone shallow repos, but strangely Bitbucket and Gitlab seemed to be more prone to these errors.
$ git clone git@.... Cloning into 'somedir'... error: RPC failed; curl 56 GnuTLS recv error (-12): A TLS fatal alert has been received. fatal: The remote end hung up unexpectedly
At some point, disabling offloading solved the issue: Disabling Offloading on Ubuntu 18.04 with Netplan and/or systemd-networkd
It apparently worked, but soon I found that only worked when using Github. Of course, that didn't make any sense. When I tried to push changes to Bitbucket or Gitlab I had again the same strange errors saying the remote host hung up unexpectedly.
I tried to debug git using
GIT_SSH_COMMAND, tried using https and even recompiled git to use OpenSSL instead of GnuTLS. Nothing seemed to work... Until I found an answer from this guy who found the solution): I needed to update my Wi-Fi drivers.
Strange error indeed.
TLDR: A bug between Hyper-V and my Wi-Fi card (Intel 5060) was causing this. Updating the drivers solved it: