Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix listing agent keys with forwarded agent #363

Merged
merged 3 commits into from
Jan 5, 2019

Conversation

yan4321
Copy link

@yan4321 yan4321 commented Dec 18, 2018

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.

case SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES:
debug("agent request %d: ssh protocol 1 is not supported", type);
r = 0;
break;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per http://api.libssh.org/rfc/PROTOCOL.agent, you'll need to return a response containing SSH_AGENT_FAILURE
SSH_AGENT_FAILURE messages are also sent in reply to unknown request types.
recommend adding a routine called process_unsupported_request() and populating "response" with SSH_AGENT_FAILURE.

@yan4321
Copy link
Author

yan4321 commented Jan 5, 2019

@manojampalam , Thank you for the observation and input!
I've adjusted the PR accordingly.

@manojampalam manojampalam reopened this Jan 5, 2019
@manojampalam manojampalam merged commit c6fa13b into PowerShell:latestw_all Jan 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants