# Problem with ssh from FreeBSD 9 to OS X Mountain Lion



## ngc5194 (Aug 21, 2015)

As FreeBSD 8.4 hit end-of-life, I upgraded a machine to FreeBSD 9.3.  Before the upgrade, I could ssh(1) from the FreeBSD 8.4 machine to my Mac OS X 8.5 machine without problems.  After upgrading the FreeBSD machine to 9.3 and making no changes to the Mac OS X machine, I cannot; the connection hangs in preauth.  To be clear, I can still ssh(1) from other Mac OS X machines to the server in question, I can ssh(1) from the FreeBSD machine to other FreeBSD machines, and I can ssh(1) from the OS X 8.5 machine back to the recently upgraded FreeBSD machine with no problem.  Everything else works, only ssh(1) from the FreeBSD 9.3 to OS X 8.5 machine has a problem that began with the upgrade.

I have made no modifications to the FreeBSD ssh client's configuration as it came out-of-the-box, and I see no uncommented changes in the ssh_config file on that machine, and no changes in that file occurred between the 8.4 instance and the 9.3 version.

When I do an `ssh -v/ssh -d` combination, the connection hangs with the client saying:

```
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
```
and the server saying:

```
debug1: expecting SSH2_MSG_KEX_DH_GEX_INIT [preauth]
```
So, somebody's lying about SSH2_MSG_KEX_DH_GEX_INIT.

These two machines are on the same network, there have been no networking changes since the upgrade, and the connection always hangs in the same place.  I could post the whole client and server debugging output, but it all looks pretty reasonable, and, modulo expected platform differences, the same between this session up to this point and those between machines where the connection works.

Something appears to be working differently between the FreeBSD 8.4 and 9.3 ssh clients, but I have no idea what.  I didn't see anything in the OpenSSH release notes between versions 6.1 and 6.6 that were suggestive, but that may not mean much.  I installed the openssh-portable port (OpenSSH 6.9) with no change in behavior.  Any ideas?


----------



## junovitch@ (Aug 25, 2015)

Strange.  I think more details, perhaps 10 lines surrounding SSH2_MSG_KEX_DH_GEX_INIT at a higher debug level, would prove helpful to know which side is at fault.  Out of curiosity, what does OSX advertise as its SSH version banner (`nc x.x.x.x 22` and Ctrl-C)?  I've never used OSX but the version number seems strange.  Just '8.5' seems old, is it 10.8.5?


----------



## ngc5194 (Aug 25, 2015)

junovitch@ said:


> Strange.  I think more details, perhaps 10 lines surrounding SSH2_MSG_KEX_DH_GEX_INIT at a higher debug level, would prove helpful to know which side is at fault.



Of course, I can't give you any lines *after* the message in question, as the whole thing hangs there until TCP timeout, but here's 15 lines prior to the point where it hangs:

`client% ssh -vvv -p 2222 server`

```
[...]
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: mac_setup: setup hmac-md5
debug1: kex: server->client aes128-ctr hmac-md5 none
debug2: mac_setup: setup hmac-md5
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<3072<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: bits set: 1484/3072
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
```

`server% /usr/sbin/sshd -ddd -p 2222`

```
[...]
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST received [preauth]
debug3: mm_request_send entering: type 0 [preauth]
debug3: mm_choose_dh: waiting for MONITOR_ANS_MODULI [preauth]
debug3: mm_request_receive_expect entering: type 1 [preauth]
debug3: mm_request_receive entering [preauth]
debug3: mm_request_receive entering
debug3: monitor_read: checking request 0
debug3: mm_answer_moduli: got parameters: 1024 3072 8192
debug3: mm_request_send entering: type 1
debug2: monitor_read: 0 used once, disabling now
debug3: mm_choose_dh: remaining 0 [preauth]
debug1: SSH2_MSG_KEX_DH_GEX_GROUP sent [preauth]
debug2: dh_gen_key: priv key bits set: 144/256 [preauth]
debug2: bits set: 1517/3072 [preauth]
debug1: expecting SSH2_MSG_KEX_DH_GEX_INIT [preauth]
```

As to whose fault it is, I have no idea.  Again, all the information I have is server saying it sent SSH2_MSG_KEX_DH_GEX_INIT and client waiting forever to receive it.  I could go play with tcpdump, but that's a PITA and I'm not familiar enough with the ssh protocol to be certain I'd be looking for the right stuff.



> Out of curiosity, what does OSX advertise as its SSH version banner (`nc x.x.x.x 22` and Ctrl-C)?  I've never used OSX but the version number seems strange.




```
SSH-2.0-OpenSSH_5.9
```



> Just '8.5' seems old, is it 10.8.5?



Yes, of course.  I figured that part was obvious.  My apologies.


----------

