-
Notifications
You must be signed in to change notification settings - Fork 711
Force IPV4 on cygwin ssh-agent connections#1344
Conversation
After upgrading to node18, our SSH connections from windows started failing and I determined that the failure was caused by git-for-windows' ssh-agent listening on the ipv4 loopback address while ssh2 was attempting to connect to the ipv6 loopback address and failing as a result.
The change in node18 that causes this bug is the following:
nodejs/node#39987
which causes node to resolve addresses in the order that windows provides them rather than forcing ipv4 addresses to come first. This causes node's net implementation to use the ipv6 loopback address by default instead of the ipv4 loopback address like previously.
The unix-socket-emulation layer behind cygwin/msys2/git-for-windows binds directly to the ipv4 loopback address and doesn't appear to be able to bind to an ipv6 address:
https://github.com/git-for-windows/msys2-runtime/blob/be826601df87b13be6038bb7e23a01d92be7ef07/winsup/cygwin/fhandler/socket_local.cc#L802
hence just forcing the ip instead of something more substantial.
We use a wrapper around ssh2 which doesn't handle this error as gracefully as modern versions of SSH2 which throw this error:
Line 371 in 739a589
| cb(new Error('Problem negotiating cygwin unix socket security')); |
Our wrapper would instead just crash the node process which was much harder to track down.
Since this address comes from cygwin's unix domain socket emulation implementation, I'm not sure there's any way to change or influence its local address preference.