darinkes / SshNet.Agent

SSH.NET Extension to authenticate via OpenSSH Agent and PuTTY Pageant
MIT License
12 stars 5 forks source link

SHA1 in RsaAgentSignature.cs (Wrong Answer SSH_AGENT_FAILURE) #5

Open bweberde opened 3 months ago

bweberde commented 3 months ago

Hi Stefan,

thanks for this project, I was looking for the Agent functionality in Ssh.Net for some time.

However, when I was trying to get the samples to work I ran into an signature error

System.Exception: Wrong Answer SSH_AGENT_FAILURE at SshNet.Agent.AgentMessage.RequestSign.From(AgentReader reader)

Since I am not a specialist in the SSH/AGENT protocols I took a wild guess and replaced the default SHA1 hash algorithm in the RsaAgentSignature constructor by SHA256 (SHA512 works as well). public RsaAgentSignature(SshAgent agent, RsaAgentKey agentKey) : this(agent, agentKey, HashAlgorithmName.SHA256) // <= { }

That fixed the above problem for me.

Regards Bernd

darinkes commented 3 months ago

Thats odd. There are extra keys to add the other Algorithms: https://github.com/darinkes/SshNet.Agent/blob/main/SshNet.Agent/SshAgentPrivateKey.cs#L22

What agent (+version) are you using? Is there any logging from it why it replies with a FAILURE message?

Thanks in advance