Question

I'm writing a utility in C# that needs to automatically connect to a server over SSH (with SSH.NET), which has been a mostly painless process. The server forces public key authentication (The server is mine, I have full physical control) so that only a few people can access it.

On Windows, we all have Pageant set up for communicating with my server using TortoiseGit, so it would make sense for me to just read the already-unlocked, in-memory private key from Pageant instead of asking for the password again every time I want to debug/run the utility.

So far the closest thing I've found is this Python module from Paramiko that checks for the existence of a Pageant window and exposes send and receive methods. This should be easy enough to port to C#, but I'm wondering exactly what command I need to send to Pageant to receive the key?

Looking through Paramiko, this isn't immediately obvious, and I can't find any sort of documentation for working with Pageant programmatically. Answers don't have to be in C#, but if they are, it would save me from having to write a small utility for it.

Was it helpful?

Solution

You don't read a private key from Pageant but ask Pageant to calculate signature. This requires modification of the client's source code.

In the latest version of our SecureBlackbox product we've added Pageant and ssh-agent support to our SSH and SFTP client components for .NET so you might want to look at them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top