Thanks for providing a useful way to diagnose. Obviously, I've changed the host names, and target ports, for security reasons in the outputs below. Note that the results are not affected by using port 22, 2000, o any other port choice. Keep reading to the end of this post, as the issue isn't related to TCP connectivity at all, as I've demonstrated, but rather an issue with the ssh client.
When going over Wifi or Ethernet, I get:
% ssh -vvv -p 823 host.example.net
OpenSSH_9.6p1, LibreSSL 3.3.6
debug1: Reading configuration data /Users/XXXXX/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/Users/XXXXX/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/Users/XXXXX/.ssh/known_hosts2'
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug3: channel_clear_timeouts: clearing
debug1: Connecting to host.example.net port 823.
debug1: Connection established.
And when over iPhone hot spot I get:
% ssh -vvv -p 823 host.example.net
OpenSSH_9.6p1, LibreSSL 3.3.6
debug1: Reading configuration data /Users/XXXXX/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/Users/XXXXX/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/Users/XXXXX/.ssh/known_hosts2'
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug3: channel_clear_timeouts: clearing
debug1: Connecting to host.example.net port 823.
ssh: connect to host host.example.net port 823: Undefined error: 0
Now, using netcat, over hot spot, it's clear TCP connects:
% nc host.example.net 823
SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.11
Because nc shows the prompt back from the target server immediately, we know the TCP session is established and SSH daemon on the target server is waiting for commands.
I can see, using tcpdump on the target server, that the nc example above results in packets and the ssh does not, both while using the iPhone as hot spot.
I do not see a routing issue as the cause here. I've looked at the routing tables on my mac.
What I do see, that offers a clue, relates to DNS:
While nc works fine with the host name, looks it up and all works properly, ssh DOES work with IP address, but fails with hostname. This is not an issue on Ethernet or non-hot-spot Wifi. As such, it appears the difference between the hot spot case and the wifi/Ethernet, is DNS resolution ONLY on the ssh command line. This is certainly curious. Before jumping to conclusions about DNS problems on the Mac, please re-read this paragraph, and note that other command line functions resolve the DNS correctly, as do Safari, Mail.app and others. This relates somehow only to something ssh is doing, and that error it produces:
ssh: connect to host host.example.net port 823: Undefined error: 0