dlech/SshAgentLib

System.IO.IOException when closing SSH connection

Closed this issue · 2 comments

I'm running into an issue using the KeeAgent 0.7.7 beta as of 2015-10-20. Not sure if this is the best place or if I should report under KeeAgent repo but the errors I'm seeing appear to be coming from this repo's code.

Environment Info:
My setup is Windows 7 / Cygwin 1.7, UAC is on the lowest setting (but not disabled). OpenSSH_6.8p1, OpenSSL 1.0.2a 19 Mar 2015. I am trying to run KeeAgent in Agent mode with the built-in SSH_AUTH_SOCK mechanism in order to use it within Cygwin and with PuTTY.

Problem:
When I open a Cygwin session (mintty / zsh) I am able to connect to a server using a key stored in KeePass (verified by turning balloon notifications on). I can open as many Cygwin sessions as I want and connect to a number of servers without any problem. However, when I exit an SSH session KeePass crashes and the following error message appears in the Event Viewer:

Application: KeePass.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.IOException
Stack:
   at dlech.SshAgentLib.PageantAgent.connectionHandler(System.IO.Stream, System.Diagnostics.Process)
   at dlech.SshAgentLib.CygwinSocket+<>c__DisplayClass17_0.<AcceptConnections>b__0()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ThreadHelper.ThreadStart()

I do not experience this issue when using PuTTY so I suspect it is related to something Cygwin is doing.

Things I have Tried:

  • Running both KeePass and Cygwin terminals as Administrator
  • Granting all Users / Groups full access to the created Cygwin SSH_AUTH_SOCK file
  • Tried converting the SSH_AUTH_SOCK path defined in Windows Environment to a Cygwin path using: export SSH_AUTH_SOCK="cygpath $SSH_AUTH_SOCK"

I was going to take a stab as debugging this further once I get some free time but if anyone has any suggestions I would love to hear them.

dlech commented

Technically, yes this is the correct place to report the bug. But since KeeAgent is the only consumer of SshAgentLib, it doesn't really matter.

It sounds like Cygwin is just closing the socket before waiting for a reply to finish. I've added a catch block to catch the unhanded exception. Please try v0.7.8, now available for download.

http://lechnology.com/software/keeagent/#download

So far so good! Thanks for the quick fix and great job on the project, one of my must-have KeePass plugins.