Fix listing agent keys with forwarded agent #363
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR attempts to fix the following problematic scenario:
When using the Windows ssh client and forwarding the agent to a remote host (specifically, RHEL 7.5 host with openssh version 7.4p1), and then trying to list the keys in the forwarded agent (ssh-add -l), no keys are returned even though the forwarded agent contains keys).
The root cause seems to be that ssh-add will first attempt to retrieve keys by sending the ssh1 protocol message SSH_AGENTC_REQUEST_RSA_IDENTITIES and then will attempt the ssh2 protocol message SSH2_AGENTC_REQUEST_IDENTITIES.
However, Windows ssh agent only implements ssh2 protocol and when processing any other type of message (including ssh1 messages) will return error code which will cause the pipe that the agent listens on to be closed which will cause the subsequent legitimate ssh2 protocol message to fail as the pipe is closed.
The proposed solution is to return an empty response for all ssh1 messages with a success code (and a debug message stating that ssh1 protocol is not supported).
This has been tested to work for the above scenario.