dlech / KeeAgent

ssh agent plugin for KeePass 2.x
http://lechnology.com/software/keeagent
Other
522 stars 35 forks source link

after first successful ssh command agent stops functioning #349

Closed dten closed 1 year ago

dten commented 1 year ago

I upgraded to the latest keeagent hoping to solve some intermitted issues I was getting which I suspected might be #338

but now after the first usage of a key the agent stops working until i restart keepass. i didn't change anything else except upgrade keeagent

image

i'm using from wsl2 via socat. https://gist.github.com/strarsis/e533f4bca5ae158481bbe53185848d49

how can i debug this?

dlech commented 1 year ago

Can you give the exact steps to reproduce the problem?

You can run KeeAgent from Visual Studio to debug.

dten commented 1 year ago

well the steps are basically in that screenshot. i have keeagent set up as per the wsl2 instructions linked. i have keys added from keepass entries. the database is unlocked and i run the commands in the screenshot. the only mystery bit would be that the location ssh'd to used one of the keys. visual studio is a good idea though :) sounds like a good start

dten commented 1 year ago

so i have it running debug in vs code

i get this error logged every time i ssh-add -l before it's broken image

i get this on the first ssh command image

afterwards repeating those commands logs no errors but does not work

dten commented 1 year ago

i checked out 8dba6e61e7bc533ba6d2c4732699a0a6d747dbc9 and i don't get errors. i will bisect later to find out where it breaks

mplattner commented 1 year ago

I experience the same problem. Unfortunately I do not have time to troubleshoot that now, so as a workaround i downgraded to v0.12.1 that works correctly.

dten commented 1 year ago

hmm i have 81fec50ce909f80f35087194e09ac512e3223bf5 checked out and i have the sshlib submodule checked out at 55ffc83ec060e6c24b58dd2075a768838a2010c8 and it is broken, if i move the submodule one commit earlier then it works again.

this fits with it being related to the windows open ssh impl

dten commented 1 year ago

the problem seems to be GetProcessById is throwing and so killing the loop that sets up new servers. it throws in the code before that commit too but its in a try catch where as this commit removed that particular catch

image

if you simply turn on breaking on exceptions you will end up hitting an exception before this (pipe broken) seems to give enough time for something to happen which results in this not throwing. however if you change that code to not use exceptions as control flow then this exception shows up instead.

adding try catch does return the behaviour to the previous state

dlech commented 1 year ago

Is this still a problem with v0.13.2?

mplattner commented 1 year ago

I've just tested v0.13.2. It does work now to create multiple direct ssh sessions after another, i.e., by executing ssh <host> in multiple terminal windows. However, when creating a nested session using agent forwarding (using ssh <host> within an existing SSH session), the "ssh key is being used"-notification pops up, but then the creation of the connecting hangs. This does work with v0.12.1 without problems.

dlech commented 1 year ago

Can you please start a new issue for the new problem with exact steps needed to reproduce the problem?

mplattner commented 1 year ago

Sure. Please see #362.

dlech commented 1 year ago

the problem seems to be GetProcessById is throwing and so killing the loop that sets up new servers

This was fixed in https://github.com/dlech/SshAgentLib/commit/c96e6d00af3198980f73c8bdcd9dc7f58afa0f57

dten commented 1 year ago

thank you for this and the concurrent requests fix 🥳