Search code examples
c#sftpprivate-keysharpssh

SharpSSH invalid privatekey


I use SharpSSH to connect to a stfp-server.

This for I need to add a privatekey-file like this:

sftp.AddIdentityFile(KeyFilePath);

But this throws an exception:

invaid privatekey: C:\KeyFile\privatekey_2.ppk

The file was created with puttygen and works with filezilla. The privatekey-type doesn't matter (SSH-1 RSA, SSH-2 RSA, SSH-2 DSA). Everytime the same result.

Do you know how to handle this problem?


Solution

  • You have to convert your key to OpenSSH Format:

    Use PuttyGen to generate and convert the key (Conversion -> export OpenSSH Key)