Git hangs with a ssh remote URI after 10.15.4 update

After updating to Catalina 10.15.4, git started hanging indefinitely when trying to push or pull from a repo that was previously accessible.

$ git push origin master
^C

The URL for origin looks like:

$ git remote -v
origin  ssh://[email protected]:30814/username/project.git (fetch)
origin  ssh://[email protected]:30814/username/project.git (push)

Attempting to ssh directly to the remote results in a hang:

$ /usr/bin/ssh -p 30814 [email protected] -vvv
OpenSSH_8.1p1, LibreSSL 2.7.3
debug1: Reading configuration data /Users/username/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 47: Applying options for *
debug1: Connecting to gitlab.example.com port 30814.
^C

Which seems to indicate the underlying problem with git is the ssh:// URI for the remote repository. I confirmed this by successfully cloning the repo using a https:// URI.


Solution 1:

Debugging steps:

  1. Attempted to connect with netcat:
$ nc -v gitlab.example.com 30814
Connection to gitlab.example.com port 30814 [tcp/*] succeeded!
SSH-2.0-OpenSSH_7.2
^C
  1. Suspecting a broken ssh client, I installed openssh using brew:
$ brew install openssh
...
$ /usr/local/bin/ssh  -V
OpenSSH_8.2p1, OpenSSL 1.1.1d  10 Sep 2019

$ /usr/local/bin/ssh -p 30814 [email protected]
Welcome to GitLab, @username!
Connection to gitlab.example.com closed.

After refreshing my shell environment to ensure that the new ssh is found in my $PATH, git operations began functioning as expected with ssh:// URIs.

Searching turned up this user submitted bug: ssh fails when using -p flag

The workaround detailed in the bug is to use the remote host's IP address instead of the DNS name. I can confirm that this worked for me:

$ /usr/bin/ssh -V
OpenSSH_8.1p1, LibreSSL 2.7.3

$ /usr/bin/ssh -p 30814 [email protected]
Welcome to GitLab, @username!
Connection to gitlab.example.com closed.

The apparent trigger for this bug is using ports greater than 8192 in conjunction with a host's DNS name.