ssh with Big Sur stuck when connecting to internet hostname with NAT loopback
Spent my morning troubleshooting an issue with ssh client of macos 11.7.1.
it would not connect to my LAN rpi using the internet hostname (via NAT loopback from modem router). Actually, sometimes it worked (1/15), most of time not. It would of course connect right away if using a local ip address. It was working fine with other ssh clients (Termius for example), or with the macos ssh client of Monterey on another mac.
would get stuck here :
christophe$ ssh -vvv -i jeedom-xxx.ddns.net pi@jeedom-xxx.ddns.net
OpenSSH_8.1p1, LibreSSL 2.7.3
debug1: Reading configuration data /Users/christophe/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 47: Applying options for *
debug1: Connecting to jeedom-xxx.ddns.net port 22.
After much trying to figure the issue, I narrowed it down to changing the default value of the ConnectTimeout in ssh_config. By default it's 0. If you set it to 10 for example, it works like a charm.
either you change it in /etc/ssh, or you pass the option via command line.
ssh -vvv -i jeedom-xxx.ddns.net -o "ConnectTimeout 10" pi@jeedom-xxx.ddns.net
just felt it was a good thing to share with the community, and up for comments if I missed something obvious that could explain this (weird) behavior.
MacBook Pro 15″